In the last posts, we looked at the code to build a HipChat Connect add-on with ASP.NET Core, run the solution in a Docker container and secure the access to the application with a valid HTTPS certificate that we got from Let’s Encrypt for free and finally deploy all of this on Azure!

One of my priority while working on new projects is to put in place Continous Integration/Continuous Delivery so that developers can develop and integrate the result of their work in a fast, efficient and easy way.

We have now all the necessary components to create that Continuous Integration and Continuous Delivery pipeline!

The goal is to have something which operates like that

  1. A developer merges something on the master branch of our Github repository
  2. It triggers a build of a Docker container image using the Dockerfile versioned in Github, which internally compile our new version of our ASP.NET Core web application
  3. In case of a successful build, it pushes the new Docker container image to a Docker repository
  4. Finally, the new Docker image is deployed as a Docker container on Azure

To fulfill those requirements, we will use Docker Cloud which lets you

Build, ship, and run - any app, anywhere

Exactly what we need!

Automate Pipelines - Set up a fully automated CI/CD workflow in minutes, from git push to production.

And as we want to use Docker the next argument is also interesting

A Single Docker Platform- Docker Cloud has everything you need to build, ship and run your Dockerized application.

So if you haven’t any Docker account you will first need to create one to be able to log in Docker Cloud.

Then you will need to link Docker Cloud to your provider, in our case Microsoft Azure.

Now that Docker Cloud can operate Microsoft Azure, the next step is to create a node. A node is a Linux host or virtual machine used to deploy and run containers. It is the equivalent of what we did with the docker-machine command line on the post “Deploying Docker containers running ASP.NET Core RC2 to Microsoft Azure Cloud“. You can get all the instruction on the page “Deploy Your First Node“.

In our case we created the following node:

Docker Cloud node

Currently, we have a machine, a node in Docker Cloud wording, so we are ready to deploy our containers on that node. We could create a service, which is a container, or a group of containers from the same Docker repository. But we are more interested in creating a stack, which specifies a group of services that make up an application, similar to Docker Compose. As we have seen in “Free HTTPS certificates for Docker containers running ASP.NET Core RC2 on Microsoft Azure,” our application is currently made of two components served as two containers:

  1. NGINX, reverse proxy and setting up Let’s Encrypt certificates
  2. Kestrel delivering our ASP.NET Core 1.0 hipchat connect web application

To create our stack, we are re-using our docker-compose.yml file set up in the previous post

which we modify slightly to describe our stack

The only difference, except the reordering, is to instruct automatic redeployment of the hipchatconnect container when an update of its image occurs in Docker Cloud registry, with the following line

autoredeploy: true

After creating the stack file and hitting the deploy button, we see the result of our stack with its two containers running on our node on Microsoft Azure!

Docker Cloud stack

Let’s have a break a moment to see what we have achieved at the moment and what remains to accomplish our goal to have a proper CI/CD pipeline and be able to deploy to production from a simple commit/merge in source code repository.
We have at the moment all the infrastructure ready. We have a node which is a machine in Azure running our application which is composed of two Docker containers.
So the last point is to connect this infrastructure to our source code repository which is a git repository on Github.

To do that we will use the Build part offered by Docker Cloud and the repositories. A repository is a collection of tagged images. When you create a service, you choose an image to use to create containers. You can read more about it on the page “Docker Cloud repositories
Then we will enable the autobuild by connecting it to our Github repository which will trigger a new build with every git push to our source code repository.

Docker Cloud Github Repository Build

Pretty impressive results in such a little effort and short time! I have built some CI/CD in the past, but it wasn’t that easy, we see clearly the potential of today’s tooling that gives us so much power as software engineers!