From c01e50342bfc1f21da45cffafc71d2b4cda8289e Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Tue, 20 Jan 2026 19:08:05 -0800 Subject: [PATCH] build: send individual shared keys for local build contexts Allows avoiding the case where two separate builds using same context name would use the same destination directory for upload. Requires updated frontend to handle these new keys. Signed-off-by: Tonis Tiigi --- build/opt.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/build/opt.go b/build/opt.go index 1642304b2..3eb746669 100644 --- a/build/opt.go +++ b/build/opt.go @@ -546,8 +546,14 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt *O } // add node identifier to shared key if one was specified + nodeID := cfg.TryNodeIdentifier() if so.SharedKey != "" { - so.SharedKey += ":" + cfg.TryNodeIdentifier() + so.SharedKey += ":" + nodeID + } + for k, v := range so.FrontendAttrs { + if strings.HasPrefix(k, "sharedkey:localdir:") { + so.FrontendAttrs[k] = v + ":" + nodeID + } } if opt.Pull { @@ -855,6 +861,13 @@ func loadInputs(ctx context.Context, d *driver.DriverHandle, inp *Inputs, pw pro return nil, err } target.FrontendAttrs["context:"+k] = "local:" + localName + sharedKey := v.Path + if p, err := filepath.Abs(sharedKey); err == nil { + sharedKey = filepath.Base(p) + } else { + sharedKey = filepath.Base(sharedKey) + } + target.FrontendAttrs["sharedkey:localdir:"+k] = sharedKey } release := func() {