-
Notifications
You must be signed in to change notification settings - Fork 476
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
Access value of buildx build --target
within Dockerfile
#2646
Comments
@thaJeztah @AkihiroSuda @crazy-max wdyt? (The issue belongs in buildkit with kind/dockerfile) |
SGTM |
I like the general idea, and could see some potential, like skipping parts of a script in intermediate stages if we know it's a used for a specific target (but should give some thought to play with additional examples / ideas). One thing that could be tricky (but maybe there's solutions for that) is if we would decide to implement expansion in stage names; Or at least, I could imagine some recursion happening in that case ( With more builtin args being added, I start to wonder if we need to consider prefix/namespace those at some point to prevent collisions with build-args that are already in use by users. |
Description
docker buildx build
has a--target
option where you can specify the desired target stage of a multi-platform build. It would be very useful for the value of this option to be accessible as a built-inARG
, perhaps one namedTARGETSTAGE
.This enhancement would make it easier to utilize some useful patterns within Dockerfiles, including navigating to a specific directory within a builder stage depending on the value of the
--target
option:Right now, doing something like this requires an extra build argument when invoking
docker buildx build
, which feels a bit cumbersome and redundant:docker buildx build --target app1 --build-arg TARGETSTAGE=app1 .
If this feature gets implemented, the build invocation would be a lot more succinct:
docker buildx build --target app1 .
There is some precedent for this sort of change because the
--platform
option has associated built-inARG
s.The text was updated successfully, but these errors were encountered: