diff --git a/build/build.go b/build/build.go index 66ec4409..d219ddb3 100644 --- a/build/build.go +++ b/build/build.go @@ -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 } diff --git a/build/localstate.go b/build/localstate.go index e05e2880..c85f3b82 100644 --- a/build/localstate.go +++ b/build/localstate.go @@ -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 } diff --git a/localstate/localstate.go b/localstate/localstate.go index 49b7a0b6..e4167684 100644 --- a/localstate/localstate.go +++ b/localstate/localstate.go @@ -12,6 +12,7 @@ import ( const refsDir = "refs" type State struct { + Target string LocalPath string DockerfilePath string }