Skip to content

Commit

Permalink
build: fix sharedkey computation for local context
Browse files Browse the repository at this point in the history
When LocalDirs were changed to LocalMounts, this broke the
sharedKey computation that was based on the context directory
path. SharedKey defines if directory is valid candidate for
incremental context transfer and if not set properly then
different directories do metadata-based transfers to same destination.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Jun 28, 2024
1 parent 8180454 commit b8da141
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions build/opt.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,9 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
}
defers = append(defers, releaseLoad)

if sharedKey := so.LocalDirs["context"]; sharedKey != "" {
if p, err := filepath.Abs(sharedKey); err == nil {
sharedKey = filepath.Base(p)
}
so.SharedKey = sharedKey + ":" + confutil.TryNodeIdentifier(configDir)
// add node identifier to shared key if one was specified
if so.SharedKey != "" {
so.SharedKey += ":" + confutil.TryNodeIdentifier(configDir)
}

if opt.Pull {
Expand Down Expand Up @@ -416,6 +414,11 @@ func loadInputs(ctx context.Context, d *driver.DriverHandle, inp Inputs, addVCSL
if err := setLocalMount("context", inp.ContextPath, target, addVCSLocalDir); err != nil {
return nil, err
}
sharedKey := inp.ContextPath
if p, err := filepath.Abs(sharedKey); err == nil {
sharedKey = filepath.Base(p)
}
target.SharedKey = sharedKey
switch inp.DockerfilePath {
case "-":
dockerfileReader = inp.InStream
Expand Down

0 comments on commit b8da141

Please sign in to comment.