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
  • Loading branch information
aaronlehmann committed Apr 14, 2021
1 parent 6d89565 commit f676dff
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 f676dff

Please sign in to comment.