-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
docker-image does not yet support --target #13934
Comments
Thanks! One question, would it make sense to be able to provide what target to build for globally (i.e. on the command line) or is it always the same target for each |
Also, I'm thinking it may be a good idea to use a little more verbose, but less ambiguous field name, perhaps |
Possibly so. With regard to the command line, possibly yes? It would eliminate the need for multiple targets (meaning pants targets, so that validates your second comment :) ). I had started doing this in preparation:
...which is a bit of unnecessary duplication, but allows the mass build of one type or another with the tags. I'm honestly undecided on whether that's too much duplication or if passing the target through with the command line would be better. In our case, we have a "local development pipeline" which builds everything with the "dev" target, and then a separate one for the production images, so we don't do it by-image on the command line typically. But if it's easy to add it as a command-line global arg, that would eliminate duplication in the BUILD files and you could "build all things tagged as containers, but only to the dev stage". |
Yea, that's kind of what I imagined it could be used for. Will do that, as I think it's worth saving in on those duplications when possible. |
Alternatively, is this an example of the need for parametrization? Currently that's achieved via multiple targets for the same entity, but #13882 speculates how we could have better first class support. |
Yes and no, I think. Wouldn't it mean it builds all variations each time? In this case, that's not desirable, unless the output image also uses the Also from the described use case by @vputz
Indicates two distinct runs, one for each target stage, so specifying which to build at run time would be needed. |
@vputz speaking of image tags.. would it be desirable to have a way to tag the images with the stage being built?.. perhaps something like: docker_image(
image_tags=["1.2-{target_stage}"],
...
) |
Parametrization probably needs a way to only run one of the cases. But yeah, to be designed. |
@kaos -- parameterization on tagging would indeed be useful, although not just for the target stage--we also currently tag by date of build and current git hash (given that it's a monorepo, this isn't optimal because two containers could be identical if an unrelated directory of the git tree changes, but would require a new hash and upload because the git hash is different. Tagging by some pants-inferred uniqueness hash only dependent on dependencies would be lovely but that's beyond my brain at the moment. |
Thanks for those tidbits of usefulness. Worth considering. There is #13724 regarding presenting |
Made a poc of the dep hash thing in #13959. |
Fascinating! Hmm, that could be really handy for us; thanks! |
Introduce a new `target_stage` field for `docker_image` as well as the `[docker].build_target_stage` option. Fixes #13934
Introduce a new `target_stage` field for `docker_image` as well as the `[docker].build_target_stage` option. Fixes pantsbuild#13934 [ci skip-rust] [ci skip-build-wheels]
(pants 2.8)
The new docker-image functionality is excellent, but does not currently support the
--target
argument ofdocker build
which allows for multistage builds (https://docs.docker.com/develop/develop-images/multistage-build/). In our application for example the containers can be build from a single Dockerfile using--target dev
to build a the "development version" of a container. It would be very useful to have this!ie
Many thanks!
The text was updated successfully, but these errors were encountered: