Road to Continuous Delivery

I love software development. Writing software is one part and somehow it needs to be delivered to your users. Remember the times when you shipped your software via FTP? In times of Docker, that should be obsolete.

  • Basic Docker and Git knowledge
Continuous Delivery

image by

There are many services promising to help you with that. But the costs for a small company could be huge, and relying on a third party when shipping your software can be dangerous. I want to accomplish that for my private docker based projects, using only open source software and my private server.

What do we need?

  • Version control
  • CI server
  • Docker Registry
  • Some server to deploy out application
Learn from OSS

How is the workflow in big Open Source projects, how do they manage their pipeline?

The following procedure I have seen often across Github.

  • Push code to Github
  • Tag a release
  • Hook for Travis runs
  • Travis runs builds runs tests
  • Container gets pushed to Docker hub
  • Container gets deployed to Digital Ocean or similar hoster

That's great for public projects, they get it for free, but how much does it cost if you're using this pipeline for closed source software?

Cost breakdown

This is just an example for a simple web project, I'm sure there are other service providers for less.

Service $ month
Github 7
Travis CI 69
Docker hub 7
Total $83

Around $80 is much money for side projects. Lets compare this to OSS solutions.

Service $ month
Gitlab 0
Gitlab CI 0
Gitlab Registry 0
Total $0

Everyone knows Github, but what is Gitlab?

GitLab unifies issues, code review, CI and CD into a single UI

Gitlab offers quite the same basic features like Github, but it tries to achieve more.
While Github focuses on integration to other services, Gitlab actually integrates solutions within the same application.

The hosted version you find on is free to use, with unlimited private repositories, CI integration, Gitlab pages and more. But you can also host it yourself. Use the prebuild Docker image or install from scratch.

Probably this sounds one sided. Do I prefer Gitlab over Github? Yes, as much I prefer to pay nothing instead of $x.

Let's do some magic

I don't want to teach anybody how to use Gitlab or git in general. There are many great getting started guides online. Let's assume you have Gitlab running or using the hosted instance. Do you have a project ready to deploy? In my case it's a small node.js application that serves something on port 3000.

FYI: I'm using Gitlab version 8.16.3.

All the magic happens in only 2 files.


FROM node:7-onbuild

EXPOSE 3000  


image: docker:git  
- docker:dind

- build
- test
- release
- deploy


  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN

  stage: build
    - docker build -t $CONTAINER_TEST_IMAGE .
    - docker push $CONTAINER_TEST_IMAGE

  stage: test
    - docker run $CONTAINER_TEST_IMAGE /script/to/run/tests

  stage: release
    - docker pull $CONTAINER_TEST_IMAGE
    - docker push $CONTAINER_RELEASE_IMAGE
    - master

  stage: deploy
  image: cdrx/rancher-gitlab-deploy
    - upgrade --stack stack-name --service app-name --new-image $CONTAINER_RELEASE_IMAGE
    - master

The config is pretty vanilla and mostly taken from Gitlab's blog.
One part that needed adjustments is the deploy section. As you see I'm using cdrx/rancher-gitlab-deploy to deploy the image to my Rancher cluster. The cluster gets notified when there is a new image version and updates it.

I care about separation of concerns, delivery shouldn't setup your server environment, in my case, the cluster is already configured and knows what to do with the incoming images.

Wrap up

Gitlab is a first class companion if you need a full stack Development/Issue/CI/Release management software. The setup is fairly easy. Project configuration is a matter of minutes and you get it all for FREE.