diff --git a/pkg/skaffold/docker/parse.go b/pkg/skaffold/docker/parse.go index b9b62249867..22c560797b3 100644 --- a/pkg/skaffold/docker/parse.go +++ b/pkg/skaffold/docker/parse.go @@ -179,7 +179,10 @@ func copiedFiles(nodes []*parser.Node) ([][]string, error) { copied = append(copied, files) } case command.Env: - envs[node.Next.Value] = node.Next.Next.Value + // one env command may define multiple variables + for node := node.Next; node != nil && node.Next != nil; node = node.Next.Next { + envs[node.Value] = node.Next.Value + } } } diff --git a/pkg/skaffold/docker/parse_test.go b/pkg/skaffold/docker/parse_test.go index c65b7088e9d..3f09944fd7e 100644 --- a/pkg/skaffold/docker/parse_test.go +++ b/pkg/skaffold/docker/parse_test.go @@ -80,6 +80,13 @@ WORKDIR ${foo} # WORKDIR /bar COPY $foo /quux # COPY bar /quux ` +const multiEnvTest = ` +FROM busybox +ENV baz=bar \ + foo=docker +COPY $foo/nginx.conf . # COPY docker/nginx.conf . +` + const copyDirectory = ` FROM nginx ADD . /etc/ @@ -293,6 +300,13 @@ func TestGetDependencies(t *testing.T) { expected: []string{"Dockerfile", "bar"}, fetched: []string{"busybox"}, }, + { + description: "multiple env test", + dockerfile: multiEnvTest, + workspace: ".", + expected: []string{"Dockerfile", filepath.Join("docker", "nginx.conf")}, + fetched: []string{"busybox"}, + }, { description: "multi file copy", dockerfile: multiFileCopy,