dockerfile: fix handling of empty build-arg also used as env#1087
Merged
tonistiigi merged 4 commits intomoby:masterfrom Jul 23, 2019
Merged
dockerfile: fix handling of empty build-arg also used as env#1087tonistiigi merged 4 commits intomoby:masterfrom
tonistiigi merged 4 commits intomoby:masterfrom
Conversation
c7460d2 to
a427541
Compare
tonistiigi
requested changes
Jul 19, 2019
Member
tonistiigi
left a comment
There was a problem hiding this comment.
Just add the args to state
a427541 to
a7acda9
Compare
Collaborator
Author
|
Updated |
d9586e7 to
6542ca1
Compare
tonistiigi
reviewed
Jul 20, 2019
| } | ||
| } | ||
| opt = append(opt, dfCmd(c)) | ||
| opt := []llb.RunOption{llb.Args(args), dfCmd(c)} |
Member
There was a problem hiding this comment.
what about the commitToHistory()? It doesn't seem to make sense to put a buildarg value there if it has been actually overridden by env. I'm not sure what the old behavior is (eg. should the arg be ignored?)
Collaborator
Author
There was a problem hiding this comment.
the ARG is there in the history with the old builder as well. That's why it was added here. If you want to revisit, maybe another PR?
Collaborator
Author
There was a problem hiding this comment.
FROM busybox
ARG foo=arg
ENV foo bar${foo:-_}baz
RUN env | grep foo= && echo foo=$foo
$ docker history $(DOCKER_BUILDKIT=0 docker build -q --progress plain --no-cache .)
IMAGE CREATED CREATED BY SIZE COMMENT
61d3d672d952 Less than a second ago /bin/sh -c env | grep foo= && echo foo=$foo 0B
00980ee6176d 2 seconds ago /bin/sh -c #(nop) ENV foo=barargbaz 0B
433321860916 2 seconds ago /bin/sh -c #(nop) ARG foo=arg 0B
e4db68de4ff2 5 weeks ago /bin/sh -c #(nop) CMD ["sh"] 0B
<missing> 5 weeks ago /bin/sh -c #(nop) ADD file:b265aa0ea2ef7ff1f… 1.22MB
$ docker history $(DOCKER_BUILDKIT=1 docker build -q --progress plain --no-cache .)
IMAGE CREATED CREATED BY SIZE COMMENT
64d260c4d5ae Less than a second ago RUN |1 foo=arg /bin/sh -c env | grep foo= &&… 0B buildkit.dockerfile.v0
<missing> 292 years ago ENV foo=barargbaz 0B buildkit.dockerfile.v0
<missing> 292 years ago ARG foo=arg 0B buildkit.dockerfile.v0
<missing> 5 weeks ago /bin/sh -c #(nop) CMD ["sh"] 0B
<missing> 5 weeks ago /bin/sh -c #(nop) ADD file:b265aa0ea2ef7ff1f… 1.22MB
With this PR I got the same:
IMAGE CREATED CREATED BY SIZE COMMENT
566c91a6293a 5 minutes ago RUN |1 foo=FOO /bin/sh -c env | grep foo= &&… 0B buildkit.dockerfile.v0
<missing> 5 minutes ago ENV foo=barFOObaz 0B buildkit.dockerfile.v0
<missing> 5 minutes ago ARG foo=arg 0B buildkit.dockerfile.v0
<missing> 28 hours ago /bin/sh -c #(nop) CMD ["sh"] 0B
<missing> 28 hours ago /bin/sh -c #(nop) ADD file:9ceca008111a4ddff… 1.22MB
Member
There was a problem hiding this comment.
how is it the same for the old builder? I don't see 1| .. for that in your output
Collaborator
Author
There was a problem hiding this comment.
Added a commit to fix this
cff273e to
09d4d69
Compare
added 4 commits
July 23, 2019 01:26
Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
09d4d69 to
4bba1b1
Compare
tonistiigi
approved these changes
Jul 23, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This bug was discovered when making #1071