Skip to content
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

Merged
merged 4 commits into from
Jul 23, 2019

Conversation

tiborvass
Copy link
Collaborator

This bug was discovered when making #1071

Copy link
Member

@tonistiigi tonistiigi left a 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

@tiborvass
Copy link
Collaborator Author

Updated

@tiborvass tiborvass force-pushed the fix-env-arg-bug branch 4 times, most recently from d9586e7 to 6542ca1 Compare July 20, 2019 00:04
}
}
opt = append(opt, dfCmd(c))
opt := []llb.RunOption{llb.Args(args), dfCmd(c)}
Copy link
Member

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?)

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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

Copy link
Member

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

Copy link
Collaborator Author

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

@tiborvass tiborvass force-pushed the fix-env-arg-bug branch 2 times, most recently from cff273e to 09d4d69 Compare July 22, 2019 23:48
Tibor Vass 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants