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

bake: support setting the context to null in bake #2906

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jsternberg
Copy link
Collaborator

@jsternberg jsternberg commented Jan 10, 2025

Setting the context to null in bake will cause the dockerfile to be sent over stdin to the build and will prevent using the default context of "." similar to how this would be used on the command line.

When the JSON is printed from bake, it will reproduce the null so subsequent uses can keep the value.

Fixes #2611.

Setting the context to null in bake will cause the dockerfile to be sent
over stdin to the build and will prevent using the default context of
"." similar to how this would be used on the command line.

When the JSON is printed from bake, it will reproduce the null so
subsequent uses can keep the value.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
@jsternberg jsternberg marked this pull request as ready for review January 13, 2025 21:18
@@ -610,7 +610,7 @@ func TestHCLContextCwdPrefix(t *testing.T) {
require.Equal(t, 1, len(m))
require.Contains(t, m, "app")
assert.Equal(t, "test", *m["app"].Dockerfile)
assert.Equal(t, "foo", *m["app"].Context)
assert.Equal(t, "cwd://foo", *m["app"].ContextPath())
Copy link
Member

Choose a reason for hiding this comment

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

cwd://foo

Was this a bug or is it a behavior change? I think a path.Clean(bi.ContextPath) is missing in this else cond: https://github.com/docker/buildx/pull/2906/files#diff-fbe2fa23203f2ff05f06b6c0731ea90529f90906807483db76a79f6018781465R1422

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It wasn't a bug but it was an artifact of this code that I removed: https://github.com/docker/buildx/pull/2906/files#diff-fbe2fa23203f2ff05f06b6c0731ea90529f90906807483db76a79f6018781465L1285

The function here seemed to be "take target as input and produce build inputs as output" but it was modifying the original target. So the cleaning of cwd://foo is happening but isn't being changed on the original target.

@thompson-shaun thompson-shaun modified the milestones: v0.20.0, v0.21.0 Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bake] Cannot specify empty context for target
3 participants