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

Support build args without explicit value #1417

Merged
merged 1 commit into from
Oct 19, 2022

Conversation

alebcay
Copy link
Contributor

@alebcay alebcay commented Oct 6, 2022

This PR fixes #1408.

When a build arg key is specified without an explicit value, the value should be taken from the corresponding environment variable on the host.

When the corresponding environment variable on the host is unset, the build arg should be ignored to avoid masking a possible default value specified in the Dockerfile. To pass an empty string as build arg, use the form VAR= on the CLI/as an environment variable.

@Zheaoli Zheaoli added this to the v0.23.1 milestone Oct 6, 2022
cmd/nerdctl/build_test.go Outdated Show resolved Hide resolved
cmd/nerdctl/build.go Outdated Show resolved Hide resolved
@alebcay alebcay force-pushed the fix-1408 branch 2 times, most recently from 91bc5db to c20c6fe Compare October 6, 2022 16:54
@AkihiroSuda AkihiroSuda requested a review from ktock October 11, 2022 15:06
cmd/nerdctl/build.go Outdated Show resolved Hide resolved
cmd/nerdctl/build.go Outdated Show resolved Hide resolved
When a build arg key is specified without an explicit value, the
value should be taken from the corresponding environment variable
on the host [1].

When the corresponding environment variable on the host is unset,
the build arg should be ignored [2] to avoid masking a possible default
value specified in the Dockerfile [3]. To pass an empty string as
build arg, use the form "VAR=" on the CLI/as an environment variable.

[1]: https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg
[2]: https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file
[3]: moby/moby#24101

Signed-off-by: Caleb Xu <[email protected]>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 06e529a into containerd:master Oct 19, 2022
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.

build --build-arg KEY with no explicit value considered an invalid value
4 participants