Merge pull request #684 from samalba/fix-input-dir-cache

revert input dir management to llb.Copy to fix cache for yarn source pkg
This commit is contained in:
Andrea Luzzardi 2021-06-21 13:13:11 +02:00 committed by GitHub
commit d887eaf045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -329,8 +329,10 @@ func (p *Pipeline) Local(ctx context.Context, op *compiler.Value, st llb.State)
if err != nil { if err != nil {
return st, err return st, err
} }
// Excludes .dagger directory by default
excludePatterns := []string{"**/.dagger/"}
if len(excludes) > 0 { if len(excludes) > 0 {
excludePatterns := []string{}
for _, i := range excludes { for _, i := range excludes {
pattern, err := i.String() pattern, err := i.String()
if err != nil { if err != nil {
@ -338,13 +340,23 @@ func (p *Pipeline) Local(ctx context.Context, op *compiler.Value, st llb.State)
} }
excludePatterns = append(excludePatterns, pattern) excludePatterns = append(excludePatterns, pattern)
} }
opts = append(opts, llb.ExcludePatterns(excludePatterns))
} }
opts = append(opts, llb.ExcludePatterns(excludePatterns))
return llb.Local( // FIXME: Remove the `Copy` and use `Local` directly.
//
// Copy'ing is a costly operation which should be unnecessary.
// However, using llb.Local directly breaks caching sometimes for unknown reasons.
return st.File(
llb.Copy(
llb.Local(
dir, dir,
opts..., opts...,
),
"/",
"/",
),
llb.WithCustomName(p.vertexNamef("Local %s [copy]", dir)),
), nil ), nil
} }