feat: disable cache-copy-layers in multistage builds; closes 2065 (#2227)
This commit is contained in:
parent
06866c0b4c
commit
239d16cd1c
|
|
@ -58,6 +58,10 @@ func ParseStages(opts *config.KanikoOptions) ([]instructions.Stage, []instructio
|
|||
return nil, nil, errors.Wrap(err, "parsing dockerfile")
|
||||
}
|
||||
|
||||
if opts.CacheCopyLayers && len(stages) >= 2 {
|
||||
return nil, nil, errors.New("kaniko does not support caching copy layers in multistage builds")
|
||||
}
|
||||
|
||||
metaArgs, err = expandNested(metaArgs, opts.BuildArgs)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "expanding meta ARGs")
|
||||
|
|
|
|||
|
|
@ -29,6 +29,39 @@ import (
|
|||
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
||||
)
|
||||
|
||||
func Test_ParseStages_NoMultistageWithCacheCopy(t *testing.T) {
|
||||
dockerfile := `
|
||||
FROM scratch as first
|
||||
COPY testfile /
|
||||
|
||||
FROM scratch as second
|
||||
COPY --from=second testfile /
|
||||
`
|
||||
tmpfile, err := ioutil.TempFile("", "Dockerfile.test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
if _, err := tmpfile.Write([]byte(dockerfile)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := tmpfile.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
opts := &config.KanikoOptions{
|
||||
DockerfilePath: tmpfile.Name(),
|
||||
CacheCopyLayers: true,
|
||||
}
|
||||
|
||||
_, _, err = ParseStages(opts)
|
||||
if err == nil {
|
||||
t.Fatal("expected ParseStages to fail on MultiStage build if CacheCopyLayers=true")
|
||||
}
|
||||
}
|
||||
|
||||
func Test_ParseStages_ArgValueWithQuotes(t *testing.T) {
|
||||
dockerfile := `
|
||||
ARG IMAGE="ubuntu:16.04"
|
||||
|
|
|
|||
Loading…
Reference in New Issue