is it possible to use `build_args` interpolation i...
# general
e
is it possible to use
build_args
interpolation inside the
docker_image.secrets
field? I'm doing this:
Copy code
docker_image(
        ...
        image_tags=["{build_args.TAG}"],
        secrets={
            "gcp": "{build_args.GOOGLE_APPLICATION_CREDENTIALS}",
        },
        ...
    )
TAG
works, but not
GOOGLE_APPLICATION_CREDENTIALS
. I do have both in
[docker.build_args]
in
pants.toml
. The docs sort of suggest it should work:
These are the common values available for all fields:
https://www.pantsbuild.org/2.21/docs/docker/tagging-docker-images#string-interpolation-using-placeholder-values but maybe I'm reading it wrong.
this is running in Github actions, and the error I get is:
Copy code
Engine traceback:
  in `publish` goal
ProcessExecutionFailure: Process 'Building docker image <image>:<tag>' failed with exit code 1.
stdout:
stderr:
ERROR: failed to stat /runner/_work/<repo name>/<repo name>/{build_args.GOOGLE_APPLICATION_CREDENTIALS}: stat /runner/_work/<repo name>/<repo name>/{build_args.GOOGLE_APPLICATION_CREDENTIALS}: no such file or directory
c
sorry for the confusion. In the paragraph preceding your excerpt:
some fields of the
docker_image
support replacing placeholder values
so, your sentence ought to have read: "these are the common values available for all fields that support interpolation:"
So for the newer fields we've overlooked the support for interpolation here, as noted by SJ here for instance: https://pantsbuild.slack.com/archives/C0D7TNJHL/p1718715936659469 I think using the
env()
var support in BUILD files could replace most uses of this interpolation feature. https://www.pantsbuild.org/2.21/docs/using-pants/key-concepts/targets-and-build-files#environment-variables
Regarding which fields does support interpolation, is for those fields that explicitly states that they do in the reference docs per field, as
image_tags
does for instance: https://www.pantsbuild.org/2.21/reference/targets/docker_image#image_tags
e
ok cool! Thanks for the details and pointer to
env
, that had slipped my notice. It should solve my problem nicely.
👍 1