1
votes

I have a web application which I want to dockerise and release using azure pipelines. I'm already able to build and test but am struggling on releasing it.

Build Pipeline (on build server controlled with VSTS agent):

1) Build using .net core
2) Run unit tests using .net core
3) Build docker image
4) Push to registry

This then automatically triggers my Release Pipeline. The release pipeline has two stages which are create release and deploy release. A non-docker scenario would be to create DLLs (create release) and deploy on web servers (deploy release). I'm not sure if/how this applies to docker apps.

Release Pipeline (a separate release agent running on each environment server):

Artifact (CI Build) => DEV => SIT => UAT => PROD

In each of the environments, I do:

1) stop and remove old image/container
2) pull 'latest' tag from repository
3) run new image in docker container.

Question: How do I create a single, release specific, docker image which can then be pushed to each environment and how do I split the create release from deploy release to get this done?

Issues:

  • If I'm just pulling an image in each pull then I'm just getting the latest tag, I am not sure if I can tag the registry image with the release number? The reason for tagging with a release number/name is so that I can re-deploy a previous release if necessary.

  • I want to prevent storing all the release images on my DEV/SIT/UAT/PROD servers. The release images need to live in the registry server so that I have a central location to pull them from.

1
You should build/push the image with particular version. But it will be build version, not the release version. Release is just "Build" + "Configuration". Check out 12factor.netVladimir Serykh
@user281921 Not get your response for several days, would you please share your latest information about this issue? If you have any concern, feel free to share it here.Hugh Lin

1 Answers

0
votes

Addressing Your Question

Your create-release job can look like this.

echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
docker build -t $CI_REGISTRY_IMAGE -t $CI_REGISTRY_IMAGE:$VERSION .
docker push $CI_REGISTRY_IMAGE
docker push $CI_REGISTRY_IMAGE:$VERSION

Your deploy release job can look like this.

echo $DOCKER_HUB_PASSWORD | docker login -u $DOCKER_HUB_USER --password-stdin $REGISTRY_URL
docker pull $CI_REGISTRY_IMAGE
docker pull $CI_REGISTRY_IMAGE:$VERSION
docker tag $CI_REGISTRY_IMAGE $DOCKER_HUB_USER/crystal-skull
docker tag $CI_REGISTRY_IMAGE:$VERSION $DOCKER_HUB_USER/$IMAGE_NAME:$VERSION
docker push $DOCKER_HUB_USER/$IMAGE_NAME
docker push $DOCKER_HUB_USER/$IMAGE_NAME:$VERSION

Addressing Your Issues

Yes, you can tag the registry image with a particular release number. This is standard for Docker registries including Docker Hub.