Preparing ASP.NET 5: Continuous Deployment with Docker and Tutum

In this article, I will tell you how to make Continuous Deployment for an ASP.NET 5 (Vnext) application based on a Docker container, Tutum , server, or cloud.

When studying Docker materials, the most questions I had were deploying my private repository to the server and automating this process, and I wanted to make it not only a solution for Azure, but also have such an opportunity for Digital Ocean or Vscale .
Circuit diagram


First you need to create a private repository on Bitbucket , you can choose any type of repository, but we will use Git in the example as the most popular. You can create a private repository on both Github (paid) and GitLab (free, but not supported by ), but it so happened historically that I mainly used bitbucket and mercurial, and now I'm switching to git.

To be able to download the repository via ssh from the docker container, we need to add the key to our account (manage Account-> SSH Keys-Add key).

Now we need to clone our repository to our machine - I do this using the Source Tree, add the new Vnext project there , add the ssh key and Dockerfile.

about beta-8, iis and vs
When working in vs using beta-8, you cannot restore packages from the studio; you need to do dnu restore from the console.
Regarding IIS, RaveNoX wrote the answer , that is, kestrel is ours, although there was no other option on mac and linux, so the problem is not great.

When using the Dockerfile for deployment, there are two approaches:

1) Make COPY - then the Dockerfile must be in the root of the project.
2) Make git clone - then the Dockerfile can be anywhere, the ssh repository key is preferably nearby.

FROM microsoft/aspnet:1.0.0-beta8
#Установим рабочую папку
#Обновимся и поставим git
RUN apt-get update && apt-get install -y git
#Добавим ключ
RUN mkdir -p /root/.ssh
ADD yourkey /root/.ssh/id_rsa
RUN chmod 700 /root/.ssh/id_rsa
RUN echo "Host yourkey "$'\n'"HostName"$'\n'"IdentityFile /root/.ssh/id_rsa" >> /root/.ssh/config
#Создадим known_hosts
RUN touch /root/.ssh/known_hosts
#Добавим bitbuckets key
RUN ssh-keyscan >> /root/.ssh/known_hosts
#копируем репозиторий
RUN git clone
# добавим в наш контейнер настройку NuGet - шаг не обязательный
RUN mkdir -p ~/.config/NuGet
RUN cd repositoryName
RUN cp /app/repositoryName/NuGet.config ~/.config/NuGet/
#восстановим зависимости
RUN dnu restore
#точка входа в контейнер
ENTRYPOINT ["sh", "/app/repositoryName/"]
cd /app/repositoryName/
dnx -p project.json kestrel

We do commit and push.

We have a project, we have a container, all this can be tested locally , the next task is to start all this on the server automatically.

We create an account or log in to . After that, you need to create a “Create Automated Build”, this can be done from the Github or Bitbucket repositories.

Create Automated Build

Fig. 1 - Create Automated Build

Now we need to configure the assembly.

Build Settings of my project

Fig. 2 - Build Settings of my project

When active, builds will happen automatically on pushes. - if the property is set, then when pushing to the repository, the assembly of a new container will be started in accordance with the settings.
Name - the branch from which to collect the project, by default it collects all branches.
Dockerfile Location - the folder in which the Dockerfile is located, namely the folder, the ability to specify your Dockerfile name is not supported. For this reason, it is convenient to use code retrieval through the repository, and not through the COPY command. On one private repository, you can collect several projects with a common code base, for example, api and workers handling long operations.
Docker tag name- tag, which is subsequently used to create a specific container.
If an assembly is selected for all branches, the Trigger button is not available and we need to push to build.
We look at the Build Details status and build log, if everything is assembled we can proceed to the next step.


We go through the docker hub on Tutum.

Add repository on Tutum

Fig. 3 - Add a repository on Tutum to create services.

Repository name - login / repository on
Username and Password from

Now configure Cloud Providers to be able to create servers from the Tutum panel.

Account info

Fig. 4 - Add links to the necessary cloud services.

Create a server (node) for publishing our services.

Create a node cluster

Fig. 5 - Add the server and its parameters, in this case DO

Deploy tags - the tag that you write in the server description to correlate the services and the machines on which they are deployed.
How to add a machine :
Click on Bring your own node - we are given a command of the form:
curl -Ls | sudo -H sh -s b5730f134e5f4674575c45a65a0ddd84

It must be done by connecting to our server via ssh.

Create a new Service


Fig. 6 - Create a Service on the Tutum

Image tag - the tag that you assigned to, if there are no tags, then you most likely incorrectly entered login \ password when adding the repository.
Deploy tags - a tag that you write in the server description to correlate the services and the machines on which they are deployed.
Ports - you need to make Published our port 5004 and assign the 80th port to it.
We click create and deploy.

Services can be created through a Stack file - a very convenient thing, it allows you to capture several services at once and quickly edit their parameters, I have 10 services now and this is just the beginning, at least I will add 3 more services ...

Stack file
image: 'login/reponame:tag'
- '80:5004'
restart: always
- tagdeploy

Now we have created and deployed the service to our server, at the address indicated in Endpoints you can see our site.
It remains to do a little magic - so that after the assembly of the new container we have it automatically redeploy .

We go into our service and select the Triggers tab .

Add trigger

Fig. 7 - Webhook for redeploy on Tutum.

We need to add the received url to the docker hub for our repository.

Add webhook

Fig. 8 - Add Webhook from Tutum

Congratulations - everything works and will automatically be deployed.
PS collapses, now it will be
Prices are pretty sad: $ 0.02 Node / hour

Also popular now: