-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dockerfile: fix handling of empty build-arg also used as env #1087
Conversation
c7460d2
to
a427541
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add the args to state
a427541
to
a7acda9
Compare
Updated |
d9586e7
to
6542ca1
Compare
} | ||
} | ||
opt = append(opt, dfCmd(c)) | ||
opt := []llb.RunOption{llb.Args(args), dfCmd(c)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is it the same for the old builder? I don't see 1| ..
for that in your output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a commit to fix this
cff273e
to
09d4d69
Compare
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
This bug was discovered when making #1071