-
Notifications
You must be signed in to change notification settings - Fork 212
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 docker build --build-context parameter #3273
Support docker build --build-context parameter #3273
Conversation
Signed-off-by: jonnyry <[email protected]>
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.
Some small comment but otherwise great work, thank you
pkg/build/buildkit/buildx_test.go
Outdated
inputArgs []string | ||
wantArgs map[string]buildx.NamedContext | ||
}{ | ||
{name: "valid args", inputArgs: []string{"A=1", "B=2=2", "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.
Just checking, are these all valid from Dockers side? I figure if you pass in "C=" and Docker tries to run it it's gonna error, no?
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.
Ah yes good point, "C=" is not.
I've taken another look and found docker buildkit has its own ParseContextNames
function with error handling (similar to the --ssh
param parsing), so I've replaced my hand rolled parseBuildContexts
with it, so we get dockers own error handling on the parameter.
This yields the following outputs from porter:
$ ./porter build --build-context
flag needs an argument: --build-context
$ ./porter build --build-context context1
Copying porter runtime ===>
Copying mixins ===>
Copying mixin exec ===>
Copying mixin terraform ===>
Copying mixin az ===>
Building bundle image
error parsing the --build-context flags: invalid context value: context1, expected key=value
unable to build bundle image: error parsing the --build-context flags: invalid context value: context1, expected key=value
unable to build bundle image: error parsing the --build-context flags: invalid context value: context1, expected key=value
$ ./porter build --build-context context1=
Copying porter runtime ===>
Copying mixins ===>
Copying mixin exec ===>
Copying mixin terraform ===>
Copying mixin az ===>
Building bundle image
[+] Building 0.0s (0/0)
error building docker image: failed to get build context context1: stat : no such file or directory
unable to build bundle image: error building docker image: failed to get build context context1: stat : no such file or directory
unable to build bundle image: error building docker image: failed to get build context context1: stat : no such file or directory
./porter build --build-context context1=..
(command successful)
1d3f82d
to
09c0c2e
Compare
…or handling (instead of own function) 2) Add toNamedContexts function and tests 3) Improve help output to make format clearer. Signed-off-by: jonnyry <[email protected]>
Good catch, thanks for that update :) |
What does this change
Add new
--build-context
parameter to porter, and pass through the value todocker build
.https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#build-context
What issue does it fix
Closes #3271
Checklist