Skip to content

Commit

Permalink
Add hack to preserve Dockerfile RUN cache compatibility after mount c…
Browse files Browse the repository at this point in the history
…ache bugfix

Signed-off-by: Aaron Lehmann <[email protected]>
(cherry picked from commit 61bb15a)
  • Loading branch information
aaronlehmann authored and tonistiigi committed Apr 22, 2021
1 parent f118d4d commit 361c2b6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions solver/llbsolver/ops/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ func (e *execOp) CacheMap(ctx context.Context, g session.Group, index int) (*sol
}
}

// Special case for cache compatibility with buggy versions that wrongly
// excluded Exec.Mounts: for the default case of one root mount (i.e. RUN
// inside a Dockerfile), do not include the mount when generating the cache
// map.
if len(op.Mounts) == 1 &&
op.Mounts[0].Dest == "/" &&
op.Mounts[0].Selector == "" &&
!op.Mounts[0].Readonly &&
op.Mounts[0].MountType == pb.MountType_BIND &&
op.Mounts[0].CacheOpt == nil &&
op.Mounts[0].SSHOpt == nil &&
op.Mounts[0].SecretOpt == nil &&
op.Mounts[0].ResultID == "" {
op.Mounts = nil
}

dt, err := json.Marshal(struct {
Type string
Exec *pb.ExecOp
Expand Down

0 comments on commit 361c2b6

Please sign in to comment.