rhythmic-battery-45198
12/21/2021, 3:36 PM"$(git log -1 --date=unix --format=%cd)-$(git rev-parse --short HEAD)"
. I see there is a note about this requiring custom plugin implementation (https://www.pantsbuild.org/docs/tagging-docker-images#tagging-images). Is there any existing examples or other places I should look before attempting to implement something? Thanks!happy-kitchen-89482
12/21/2021, 3:38 PMrhythmic-battery-45198
12/21/2021, 3:38 PMrhythmic-battery-45198
12/21/2021, 3:40 PMrhythmic-battery-45198
12/21/2021, 4:15 PMcurved-television-6568
12/21/2021, 4:26 PMeager-dress-66405
12/21/2021, 5:13 PM[docker]
build_args = [
# To set when packaging:
# COMMIT_SHA="$(git rev-parse --short HEAD)"
# export PANTS_DOCKER_BUILD_ARGS="['COMMIT_SHA=$COMMIT_SHA']"
"COMMIT_SHA=SETME"
]
macros.py
(or individually for each docker_image
target):
def tagged_docker_image(**kwargs):
...
kwargs["image_tags"] = [
# Pant"s doesn't expose the commit sha and we need to set PANTS_DOCKER_BUILD_ARGS="['COMMIT_SHA=$(git rev-parse --short HEAD)']" when this is packaged.
# <https://github.com/pantsbuild/pants/issues/13724>
"{build_args.COMMIT_SHA}",
]
docker_image(**kwargs)
And then in when packaging (in a GHA for us):
COMMIT_SHA="$(git rev-parse --short HEAD)"
export PANTS_DOCKER_BUILD_ARGS="['COMMIT_SHA=$COMMIT_SHA']"
...
./pants package $target
rhythmic-battery-45198
12/21/2021, 5:52 PMDOCKER_TAG=$(./build-support/docker-tag.sh) ./pants publish docker/geminus-ui
rhythmic-battery-45198
12/21/2021, 5:54 PMdocker-tag.sh
script constructs and echos the tag based on the git sha.rhythmic-battery-45198
12/21/2021, 5:54 PMmacros.py
is a nice touch to remove duplication 👍