https://pantsbuild.org/ logo
c

curved-microphone-39455

01/12/2023, 9:07 PM
What would be the best way to achieve the
publish
Goal for
docker_image
to put a dynamic Tag, I have already have a Git Tag with
semver
accessible at this moment in my ci/cd, so if I have
1.2.3
, how could I publish to my repository using the same tag
1.2.3
?
c

curved-television-6568

01/12/2023, 9:10 PM
h

high-yak-85899

01/12/2023, 9:10 PM
You can set up a build args section in
pants.toml
like this
Copy code
[docker]
build_args = [
  "MY_DYNAMIC_TAG",
]
and then amend your build target like such
Copy code
docker_image(
    name="docker",
    repository="my_image_name",
    image_tags=["{build_args.MY_DYNAMIC_TAG}"],
)
c

curved-microphone-39455

01/12/2023, 9:12 PM
and on runtime I can have the Environment Variable
MY_DYNAMIC_TAG=1.2.3
and this will forward
to the build and tag correctly
h

high-yak-85899

01/12/2023, 9:12 PM
It will!
It will actually complain if that environment variable isn't set
c

curved-microphone-39455

01/12/2023, 9:12 PM
Cool thanks!
3 Views