When building a docker image with a dynamic tag, w...
# general
b
When building a docker image with a dynamic tag, what's the best way to capture this for use by other processes? For context, we want to have 'content-addressed' docker images (managed by pants, rather than docker's caching) with a tag like
image_tags=["{pants.hash}"]
and stick this into a CloudFormation template to have the image running in AWS as a Lambda or Fargate service or whatever. The only approaches I can determine are not so good: 1. capture it out of the logging of a
./pants package ...
call: our system is then doing automatic processing of human facing messaging 2. looking at the most recent row of `docker images --format '{{.Tag}}' $my_repository`: we have to write the repository out in yet another place, and, with caching/content-addressing, there's no guarantee that the most recently created image is the one that's been created as part of the current build 3. (there doesn't appear to be anything recorded in
dist/
, despite this being a
package
call; and something like
peek
gives me seems to give me
image_tags
before formatting)
w
My team is also interested in thoughts here, currently we do approach 1.
👍 1
albeit we capture the sha instead of the tag(s)
b
For 3. Since the "artifact" is a docker image there's nothing to write to
dist
. Although the image ID wouldn't be wrong to write 🤔
FWIW we (and I think I remember others here) just parse the output 🤷‍♂️
b
Ah, interesting. Would it make sense to write a
dist/path.to.target/target_name.json
file containing info like the repositories, tags and image ID?
b
Slap some extension before the json and you have my vote:
foo.docker_info.json
👍 1
b
b
It should be pretty simple all things considered to implement. Let me know if you're interested! I/we are happy to help you along