-
Notifications
You must be signed in to change notification settings - Fork 503
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
base: master
Are you sure you want to change the base?
Conversation
e1f381b
to
ecfda8f
Compare
e05f59d
to
467c00d
Compare
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]>
467c00d
to
3989770
Compare
@@ -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()) |
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.
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
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.
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.
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.