Got a docker question. I'd like to avoid prolifera...
# general
h
Got a docker question. I'd like to avoid proliferating our AWS ECR registry ID around our repo (since it's complicated). The
pants.toml
setting was great to set up something like
[docker.registries.aws-ecr]
so that I could refer to them. However, one of my images depends on a base image we store in that registry. It seems like I still have to do
FROM <my long registry ID>/<image name>:<image tag>
instead of just
FROM <image name>:<image tag>
. My target configuration looks like this
Copy code
docker_image(
    name = "gnc_ground",
    registries = ["@aws-ecr"],
    tags = ["ground_software_service"],
)
Any clever way to avoid having to write out the long registry ID in the
Dockerfile
as well?
f
In a non-Pants use of Docker, I’ve done:
Copy code
ARG base_image
FROM ${base_image}
(since it is a Dockerfile where we always build via a script that injects the base image from common config)
h
Hmm, so maybe I can use build_args to configure that globally
That seems to work!
c
Yeah, perhaps support to pickup registry addresses as build args would be useful; but the workaround you found is ok, only not DRY.
h
Yeah, at least the duplication is collocated in
pants.toml
so it's not too bad for now.
👍 1
c
Note as well as there is magic in place if you ever need to use another docker_image target as base..
h
I did a slightly modified version of this where I set
Copy code
[docker]
build_args = ["ECR_ID=<my registry ID>"]
and then in the Dockerfile, I did
Copy code
ARG ECR_ID
FROM ${ECR_ID}/<base image>:<image tag>
. Hopefully that keeps each
Dockerfile
more tunable.
👍 2