From 1a0c82690166656b62f372068d77a2929f1546d7 Mon Sep 17 00:00:00 2001 From: Talon Bowler Date: Wed, 10 Jul 2024 12:51:09 -0700 Subject: [PATCH] Document CopyIgnoredFile check as initially experimental. Signed-off-by: Talon Bowler --- frontend/dockerfile/dockerfile2llb/convert.go | 6 ++---- frontend/dockerui/config.go | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/dockerfile/dockerfile2llb/convert.go b/frontend/dockerfile/dockerfile2llb/convert.go index e1aa8e6aeec56..4dfcda0055945 100644 --- a/frontend/dockerfile/dockerfile2llb/convert.go +++ b/frontend/dockerfile/dockerfile2llb/convert.go @@ -600,7 +600,7 @@ func toDispatchState(ctx context.Context, dt []byte, opt ConvertOpt) (*dispatchS if err != nil { return nil, err } - if len(dockerIgnorePatterns) > 0 { + if len(dockerIgnorePatterns) > 0 && opt.Client.CopyIgnoredCheckEnabled { dockerIgnoreMatcher, err = patternmatcher.New(dockerIgnorePatterns) if err != nil { return nil, err @@ -668,7 +668,6 @@ func toDispatchState(ctx context.Context, dt []byte, opt ConvertOpt) (*dispatchS sourceMap: opt.SourceMap, lint: lint, dockerIgnoreMatcher: dockerIgnoreMatcher, - copyIgnoredCheckEnabled: opt.Client.CopyIgnoredCheckEnabled, } if err = dispatchOnBuildTriggers(d, d.image.Config.OnBuild, opt); err != nil { @@ -844,7 +843,6 @@ type dispatchOpt struct { sourceMap *llb.SourceMap lint *linter.Linter dockerIgnoreMatcher *patternmatcher.PatternMatcher - copyIgnoredCheckEnabled bool } func getEnv(state llb.State) shell.EnvGetter { @@ -1898,7 +1896,7 @@ func addReachableStages(s *dispatchState, stages map[*dispatchState]struct{}) { } func validateCopySourcePath(src string, cfg *copyConfig) error { - if cfg.ignoreMatcher == nil || !cfg.opt.copyIgnoredCheckEnabled { + if cfg.ignoreMatcher == nil { return nil } cmd := "Copy" diff --git a/frontend/dockerui/config.go b/frontend/dockerui/config.go index 26f1d8835a53d..e0f9658aaa285 100644 --- a/frontend/dockerui/config.go +++ b/frontend/dockerui/config.go @@ -289,6 +289,9 @@ func (bc *Client) init() error { } } + // CopyIgnoredCheckEnabled is an experimental feature to check if COPY is ignored by .dockerignore, + // and it is disabled by default. It is expected that this feature will be enabled by default in a future + // release, and this build-arg will be removed. if v, ok := opts[keyCopyIgnoredCheckEnabled]; ok { bc.CopyIgnoredCheckEnabled, err = strconv.ParseBool(v) if err != nil {