mirror of
https://github.com/docker/buildx.git
synced 2024-11-22 15:37:16 +08:00
build: set target to local state
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
cc6957d1cc
commit
2134a1e104
@ -423,6 +423,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
|
||||
}
|
||||
|
||||
so := client.SolveOpt{
|
||||
Ref: identity.NewID(),
|
||||
Frontend: "dockerfile.v0",
|
||||
FrontendAttrs: map[string]string{},
|
||||
LocalDirs: map[string]string{},
|
||||
@ -665,12 +666,6 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
|
||||
so.FrontendAttrs["ulimit"] = ulimits
|
||||
}
|
||||
|
||||
// remember local state like directory path that is not sent to buildkit
|
||||
so.Ref = identity.NewID()
|
||||
if err := saveLocalState(so, opt, node, configDir); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return &so, releaseF, nil
|
||||
}
|
||||
|
||||
@ -748,6 +743,9 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := saveLocalState(so, k, opt, node, configDir); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for k, v := range gitattrs {
|
||||
so.FrontendAttrs[k] = v
|
||||
}
|
||||
|
@ -8,15 +8,13 @@ import (
|
||||
"github.com/moby/buildkit/client"
|
||||
)
|
||||
|
||||
func saveLocalState(so client.SolveOpt, opt Options, node builder.Node, configDir string) error {
|
||||
func saveLocalState(so *client.SolveOpt, target string, opts Options, node builder.Node, configDir string) error {
|
||||
var err error
|
||||
|
||||
if so.Ref == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
lp := opt.Inputs.ContextPath
|
||||
dp := opt.Inputs.DockerfilePath
|
||||
lp := opts.Inputs.ContextPath
|
||||
dp := opts.Inputs.DockerfilePath
|
||||
if lp != "" || dp != "" {
|
||||
if lp != "" {
|
||||
lp, err = filepath.Abs(lp)
|
||||
@ -35,12 +33,12 @@ func saveLocalState(so client.SolveOpt, opt Options, node builder.Node, configDi
|
||||
return err
|
||||
}
|
||||
if err := ls.SaveRef(node.Builder, node.Name, so.Ref, localstate.State{
|
||||
Target: target,
|
||||
LocalPath: lp,
|
||||
DockerfilePath: dp,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
const refsDir = "refs"
|
||||
|
||||
type State struct {
|
||||
Target string
|
||||
LocalPath string
|
||||
DockerfilePath string
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user