I’ve tried to find best practice for tagging images from nightly builds in a CI test environment, but haven’t really found what I’m looking for. My question is how to tag the nightly build images, how to specify them in the stack YML files, and how to clean up old images from our DTR.
Our work-flow looks like this:
- Fetches artifacts from nightly build
- Builds new docker images
- Tags images
- Pushes images to our DTR
Docker Enterprise test environment (with 3 nodes):
- Redeploy some stacks with the new images
So far we’ve simply tagged all nightly builds with
nightly and specified that in the YML files. But sometimes some images don’t get updated, even when we do
docker stack rm before
docker stack deploy. So we’ve been recommended to tag each image version with a unique tag, but that seems to have some serious disadvantages to me, and I would like to know how to do it best.
(A) We need to be sure that the stacks are running the latest images.
(B) Update of stacks every night must be automated.
(C.) Old nightly build images must be cleaned from our DTR.
With (A) I mean that when a stack is redeployed and a container to be started on some node, it should be based on the new image, regardless of other containers of other stacks that might still run an older version.
(B) means that I would really prefer if services in stack YML files could specify a sort of "channel" so that they get the latest image of a certain kind, like "last-nightly-build" or "latest-release", rather than having to specify explicit build numbers in YML files.
By (C.) I mean that in case the solution involves tagging nightly builds with a unique build number, then I need a script to delete old images from the DTR. I know of the DTR API, but it looks like it could need some programming effort to recognise and delete images from old nightly builds while keeping the newer ones as well as old released versions.