Allow "default" tag on docker image
Is your feature request related to a problem? Please describe.
Developers don't care about the tag much and "latest" is a good default.
On CI, however, we want the tag to be the version.
Currently there's no way to default to "latest" and ALSO allow customizing to the version.
Describe the solution you'd like
./pants package myimg -> "latest"
TAG=v1.2.3 ./pants package myimg -> "latest"
Describe alternatives you've considered Plugins, injecting env vars, combo of the existing options.
Additional context :pray:
This would be great for then Helm deploy implementation.
Current PoC chooses the first tag it finds that is not latest. Having an user-chosen default would improve this greatly.
The example both point to -> "latest"... assuming the latter is for -> "v1.2.3 ?
See #17633 for how to provide a default tag that is overridable.
# BUILD
docker_image(name="img", tag=["{build_args.TAG}"])
# pants.toml
[docker]
build_args = ["TAG"]
# .pants.bootstrap
: ${TAG:=default}
─❯ TAG=v1.2.3 ./pants package //:img
Actually, if #17652 lands, this will be insanely simpler:
# BUILD
docker_image(name="img", tags=[env("TAG", "default")])
Actually, if #17652 lands, this will be insanely simpler:
# BUILD docker_image(name="img", tags=[env("TAG", "default")])
@thejcannon re-open if you're not happy with the above.. ;)
I found I needed to also export the ENV variable in .pants.bootstrap
# .pants.bootstrap
: ${TAG:=default}
EXPORT TAG