echoing-farmer-15630
01/10/2022, 2:44 PMgit log -1 --pretty=%H
to get the SHA. So the idea is that we'd tag each container both with a "git hash" (which would be different for each build) and a "pants hash" (which ideally wouldn't change unless the input context changed). We wouldn't deploy a container unless the "Pants hash" changed, but with the "git hash" on there we could look up the commit.
Second--this is possibly better handled by the docker tooling, but since it relates--is it possible to get information about targets (in this case, such as the pants-hash) in any form, particularly human-readable? In other words, it would be nice (again, no need for extra work yet!) to say "okay, once we've built these, what would the image names and tags be of all the built containers in this repository?" so that we could then programmatically update deployments.
I know some of this may fall outside the purview of the build tool itself, but this is great stuff for us and it's also just fun to learn.enough-analyst-54434
01/10/2022, 2:48 PMenough-analyst-54434
01/10/2022, 2:51 PMcurved-television-6568
01/10/2022, 2:52 PM$ GIT_COMMIT=$(git rev-parse HEAD) ./pants package src/example:demo
curved-television-6568
01/10/2022, 2:53 PMpeek
will not reveal the final image name with registries and tags with all values interpolated.curved-television-6568
01/10/2022, 2:54 PMpublish
to push the images, you can get a readable output in json format detailing what was just published. See https://www.pantsbuild.org/v2.9/docs/reference-publish#section-outputcurved-television-6568
01/10/2022, 2:56 PM$ jq . publish.json
[
{
"exit_code": 0,
"names": [
"<http://docker.registry.name/oryd/kratos:v0.7.6-alpha.1|docker.registry.name/oryd/kratos:v0.7.6-alpha.1>"
],
"published": true,
"publisher": "docker",
"registries": [
"<all default registries>"
],
"status": "published",
"target": "docker:kratos-images#oryd_kratos"
},
...
echoing-farmer-15630
01/10/2022, 2:57 PMechoing-farmer-15630
01/10/2022, 2:58 PMcurved-television-6568
01/10/2022, 2:58 PMechoing-farmer-15630
01/10/2022, 3:12 PM