feat: disable cache-copy-layers in multistage builds; closes 2065 (#2227)

This commit is contained in:
dmr
2022-08-25 21:36:56 -04:00
committed by GitHub
parent 06866c0b4c
commit 239d16cd1c
2 changed files with 37 additions and 0 deletions
+33
View File
@@ -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"