Substitute build args from config into parsed Dockerfile before processing deps#828
Conversation
cmd/skaffold/app/cmd/docker/deps.go
Outdated
| func runDeps(out io.Writer, filename, dockerfile, context string) error { | ||
| config, err := cmdutil.ParseConfig(filename) | ||
| if err != nil { | ||
| return err |
| func runContext(out io.Writer, filename, context string) error { | ||
| config, err := cmdutil.ParseConfig(filename) | ||
| if err != nil { | ||
| return err |
cmd/skaffold/app/cmd/docker/deps.go
Outdated
|
|
||
| func getBuildArgsForDockerfile(config *config.SkaffoldConfig, dockerfile string) map[string]*string { | ||
| for _, artifact := range config.Build.Artifacts { | ||
| if artifact.DockerArtifact != nil && artifact.DockerArtifact.DockerfilePath == dockerfile { |
There was a problem hiding this comment.
Should we compare normalized paths?
There was a problem hiding this comment.
Good call. I also realized this was using the top level skaffold.yaml even if the user provided a relative path to the dockerfile which was breaking some scenarios, so I added logic to infer the path to the skaffold.yaml if it's not provided. PTAL
pkg/skaffold/docker/parse.go
Outdated
| var RetrieveImage = retrieveImage | ||
|
|
||
| func readDockerfile(workspace, absDockerfilePath string) ([]string, error) { | ||
| func readDockerfile(buildArgs map[string]*string, workspace, absDockerfilePath string) ([]string, error) { |
There was a problem hiding this comment.
nit: would have added those arguments last
|
Hey @nkubala what do you think about adding a new test case or expanding the existing unit tests to cover this case that was failing? (or maybe it's already covered and i'm missing it?) |
|
@bobcatfish added a test |
|
Any news on this feature? ARG MY_ARG=default_value |
This PR passes the buildArgs from Docker artifacts in skaffold.yaml to the Docker dependency parser, which substitutes the args into the parsed Dockerfile AST before processing any other commands. This allows args to be substituted correctly when provided as a build arg and implicitly referenced in a Dockerfile, e.g.
skaffold.yaml
Dockerfile
will now copy
bar.txtto/tmp/bar.txt.Fixes #777