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 CACHE when used with WITH DOCKER #2549

Merged
merged 1 commit into from
Jan 6, 2023
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 @@ -18,6 +18,7 @@ All notable changes to [Earthly](https://github.com/earthly/earthly) will be doc
- Support for saving files larger than 64kB on failure within a `TRY/FINALLY` block. [#2452](https://github.com/earthly/earthly/issues/2452)
- Fixed race condition where `SAVE IMAGE` or `SAVE ARTIFACT AS LOCAL` commands were not always performed when contained in a target that was referenced by both a `FROM` (or `COPY`) and a `BUILD` command within the context of a `WAIT`/`END` block. [#2237](https://github.com/earthly/earthly/issues/2218)
- `WORKDIR` is lost when `--use-copy-link` feature is enabled with `GIT CLONE` or `COPY --keep-own` commands. [#2544](https://github.com/earthly/earthly/issues/2544)
- The `CACHE` command did not work when used inside a `WITH DOCKER` block. [#2549](https://github.com/earthly/earthly/issues/2549)

## v0.6.30 - 2022-11-22

Expand Down
4 changes: 4 additions & 0 deletions earthfile2llb/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,10 @@ func (c *Converter) WithDockerRun(ctx context.Context, args []string, opt WithDo

enableParallel := allowParallel && c.opt.ParallelConversion && c.ftrs.ParallelLoad

for _, cache := range c.persistentCacheDirs {
opt.extraRunOpts = append(opt.extraRunOpts, cache)
}

if c.ftrs.UseRegistryForWithDocker {
wdr := newWithDockerRunRegistry(c, enableParallel)
return wdr.Run(ctx, args, opt)
Expand Down
2 changes: 2 additions & 0 deletions earthfile2llb/withdockerrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type WithDockerOpt struct {
ComposeFiles []string
ComposeServices []string
TryCatchSaveArtifacts []debuggercommon.SaveFilesSettings
extraRunOpts []llb.RunOption
}

type withDockerRunTar struct {
Expand Down Expand Up @@ -217,6 +218,7 @@ func (w *withDockerRunTar) Run(ctx context.Context, args []string, opt WithDocke
"/var/earthly/dind", pllb.Scratch(), llb.HostBind(), llb.SourcePath("/tmp/earthly/dind")))
crOpts.extraRunOpts = append(crOpts.extraRunOpts, pllb.AddMount(
dockerdWrapperPath, pllb.Scratch(), llb.HostBind(), llb.SourcePath(dockerdWrapperPath)))
crOpts.extraRunOpts = append(crOpts.extraRunOpts, opt.extraRunOpts...)

var tarPaths []string
for index, tl := range w.tarLoads {
Expand Down
2 changes: 2 additions & 0 deletions earthfile2llb/withdockerrunreg.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ func (w *withDockerRunRegistry) Run(ctx context.Context, args []string, opt With
"/var/earthly/dind", pllb.Scratch(), llb.HostBind(), llb.SourcePath("/tmp/earthly/dind")))
crOpts.extraRunOpts = append(crOpts.extraRunOpts, pllb.AddMount(
dockerdWrapperPath, pllb.Scratch(), llb.HostBind(), llb.SourcePath(dockerdWrapperPath)))
crOpts.extraRunOpts = append(crOpts.extraRunOpts, opt.extraRunOpts...)

dindID, err := w.c.mts.Final.TargetInput().Hash()
if err != nil {
return errors.Wrap(err, "make dind ID")
Expand Down