Can explicit build_args for the docker subsystem b...
# general
n
Can explicit build_args for the docker subsystem be overridden by environment variables provided to the pants environment during
./pants package
? I.e. if I have explicit values set for a build_arg through the
pants.toml
or
extra_build_args
field on my
docker_image
target, simply setting a environment variable in the pants environment does not overwrite the explicit value - however if there is no explicit value set - setting the environment variable does get passed through to the build. This seems a little odd but I can understand why this isn't seen as an issue because it only really becomes a problem when I try to use a build_arg to dynamically tag my images. I can provide additional details if need be.
My motivation is that I have a docker_image target being tagged with
image_tags=["{build_args.IMAGE_TAG}"]
but I want to be able to provide a default tag if that
IMAGE_TAG
env var is not set. Currently
./pants package path_to_my_build:image
understandably does not work because
IMAGE_TAG
is not defined. If I define a explicit value in the build_args sections of
pants.toml
or
extra_build_args
section the environment variable is never taken into account.
FWIW both the docs and
./pants help-advanced docker
never imply that what I am trying to do is possible and they seem to quite deliberately not call the values set in the build_args section of
pants.toml
or
extra_build_args
defaults and instead call them "explicit values"
c
You may provide a default value in your dockerfile. I think it will be picked up for the interpolation context as well, iirc.
I.e. ARG name=value
n
Appreciate the quick response - I will give that a try!
👍 1