Deploy using Semver for docker images hosted by AWS ECS

  amazon-ecs, azure-devops, docker

I’ve got an Azure DevOps pipeline that builds and pushes docker images to an AWS ECS Repository using SemVer tags. E.g. 1.0.0, 1.0.1, etc.

Can someone tell me how I can automate a next stage in my pipeline to deploy the version that was just built? e.g. the stage should update my ECS Task Definition to use image:1.0.1, and then update my service to use the latest task definition.

All the articles I’ve seen just use :latest and then they just do a force-new-deployment. Quite frankly, I think that’s a silly way to do things. What if your PROD container crashes and has to be restarted while it’s NOT on the latest version? It’s going to start up PROD using the latest version which will cause big problems.

My full scenario is, I want to have a single image repo, which will contain all the version of my images. UAT and PROD will be pulling from there, based on the version I want to use as specified in my build pipeline.

Say I’m on 1.0.0 in UAT and PROD.
I kick off a multi stage build pipeline, it will build 1.0.1 and push the image up. I want UATs task definition to now be auto updated to 1.0.1 and then do a new deployment. PROD still points to 1.0.0. Even if I stop it, and start it again, it should still point to 1.0.0.

Now after UAT, as part of my approval, I approve my PROD release. This updates PROD’s task definition to point to 1.0.1 and it forces a new deployment….

Maybe I’ve got the cat by the tail, so please let me know if that is too far fetched, or what the story is.

Thanks for your time,

Source: Docker Questions