pants icon indicating copy to clipboard operation
pants copied to clipboard

Allow "default" tag on docker image

Open thejcannon opened this issue 3 years ago • 1 comments

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:

thejcannon avatar Jul 29 '22 10:07 thejcannon

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.

alonsodomin avatar Jul 29 '22 21:07 alonsodomin

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

kaos avatar Nov 27 '22 13:11 kaos

Actually, if #17652 lands, this will be insanely simpler:

# BUILD
docker_image(name="img", tags=[env("TAG", "default")])

kaos avatar Nov 27 '22 13:11 kaos

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.. ;)

kaos avatar Feb 21 '23 15:02 kaos

I found I needed to also export the ENV variable in .pants.bootstrap

# .pants.bootstrap
: ${TAG:=default}
EXPORT TAG

levous avatar Mar 03 '23 21:03 levous