Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WITH DOCKER cache bust for some images #2367

Merged
merged 2 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ All notable changes to [Earthly](https://github.com/earthly/earthly) will be doc

- `CACHE` command was not being correctly used in `IF`, `FOR`, `ARG` and other commands. [#2330](https://github.com/earthly/earthly/issues/2330)
- Fixed buildkit gckeepstorage config value which was was set to 1000 times larger than the cache size, now it is set to the cache size.
- Fixed Earthly not detecting the correct image digest for some images loaded in `WITH DOCKER --load` and causing cache not to be bust correctly. [#2337](https://github.com/earthly/earthly/issues/2337) and [#2288](https://github.com/earthly/earthly/issues/2288)

## v0.6.28 - 2022-10-26

Expand Down
13 changes: 10 additions & 3 deletions builder/image_solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,17 @@ func (m *multiImageSolver) SolveImages(ctx context.Context, imageDefs []*states.
}

for k, v := range resp {
if !strings.HasPrefix(k, result.FinalImageName+"|") {
pref1 := result.FinalImageName + "|"
pref2 := fmt.Sprintf("docker.io/library/%s|", result.FinalImageName)
var k2 string
switch {
case strings.HasPrefix(k, pref1):
k2 = strings.TrimPrefix(k, pref1)
case strings.HasPrefix(k, pref2):
k2 = strings.TrimPrefix(k, pref2)
default:
continue
}
k2 := strings.TrimPrefix(k, result.FinalImageName+"|")
switch k2 {
case exptypes.ExporterImageDescriptorKey:
vdec, err := base64.StdEncoding.DecodeString(v)
Expand All @@ -257,7 +264,7 @@ func (m *multiImageSolver) SolveImages(ctx context.Context, imageDefs []*states.
}
if result.ImageDigest == "" {
// TODO: This should use console.
fmt.Printf("Warning: Could not detect digest for image %s. Please update your buildkit installation.\n", result.FinalImageName)
fmt.Fprintf(os.Stderr, "Warning: Could not detect digest for image %s. Please update your buildkit installation.\n", result.FinalImageName)
}
results[i] = result
}
Expand Down