rapid-exabyte-76685
04/25/2022, 11:59 PMdocker_image(
...
image_tags=[
"{build_args.BRANCH}"
]
)
where BRANCH
is included in [docker] env_vars
and [docker] build_args
(is it correct that it should be included in both places?) ... and if BRANCH
has upper-case characters it looks like the tags on the image are all in lower case. Or maybe this is by design?curved-television-6568
04/26/2022, 5:28 AM(is it correct that it should be included in both places?)No, if you want to pick up the
BRANCH
from the envrionment Pants is running in, it is enough to list it in [docker] build_args
or on the docker_image
target with extra_build_args
without a value (i.e. as BRANCH
not as BRANCH=some-value
)
https://www.pantsbuild.org/docs/tagging-docker-images#using-env-vars-to-include-dynamic-data-in-tags
upper-case characters […] are all in lower caseYes, this is by design, for two reasons. a) First, since this is the required format for an image name: https://docs.docker.com/engine/reference/commandline/tag/#extended-description
An image name is made up of slash-separated name components, optionally prefixed by a registry hostname. The hostname must comply with standard DNS rules, but may not contain underscores. If a hostname is present, it may optionally be followed by a port number in the formatThis continues however with. If not present, the command uses Docker’s public registry located at:8080
by default. Name components may contain lowercase letters, digits and separators. A separator is defined as a period, one or two underscores, or one or more dashes. A name component may not start or end with a separator.<http://registry-1.docker.io|registry-1.docker.io>
A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes.Which I’ve overlooked when implementing this, so Pants is currently forcing the tag to be lowercase, although that is not required (but may be a good idea, given the next point for lowercasing the image name) - but I consider this a bug, though (that the tag part is forced to lowercase as well). b) Looking at the bigger picture, where the image name may be referenced in other tools/systems, there are cases where the image name may be transformed (to lowercase) in which case it will be really difficult to restore to the original casing for subsequent steps (the Docker registry is case sensitive). This may sound a bit random, but is a real case we’ve had issues with (for more scenarios than image names) at my work.
curved-television-6568
04/26/2022, 5:39 AMcurved-television-6568
04/26/2022, 5:40 AMrapid-exabyte-76685
04/26/2022, 6:03 AMpublish
step to work with the gcloud auth as mentioned in a previous thread, although I can run package
just fine and then I get tripped up when I run docker push some-image-name:$BRANCH
... the package
has tagged with $BRANCH
converted to lower-case but in the rest of my script $BRANCH
was obviously still in mixed case... however I've updated my script to force to lower-case.
I'll see if I can get publish
working with the gcloud auth as well.curved-television-6568
04/26/2022, 6:39 AMcurved-television-6568
04/26/2022, 9:35 AM