Dockerize your builds in GitLab CI

Dockerize your builds in GitLab CI
november 7, 2016 Martin Woxneryd

GitLab CI is an CI/CD tool integrated directly into GitLab CI uses a distributed approach for running its jobs and offers shared runners running on Digital Ocean. They also have Docker support and even an integrated Docker registry for each project. This short (four source files) tutorial will show how you can deploy your own Dockerized build environment and use that in the CI pipeline of your service.


First we define our build environment through ad Dockerfile. In this example I’m going to build a Standalone Spring Boot application so I start with a Java based image and then installs the Spring Boot CLI.


We then define the CI integration in a .gitlab-ci.yml file that will be automatically picked up by GitLab CI. The runner used here is docker based with support for docker-in-docker (i.e. we can run Docker commands from within the runner). This gives us the ability to build our image and publish it to the built in registry.


Now let’s define a service that we will build with our newly created builder. It’s a simple Spring Boot application in Groovy.


And finally we can tell GitLab CI to use our Dockerized build environment when building our service. At the end we specify the artifacts, an executable fat jar in this case, that will be downloadable from GitLab.

With Docker support in GitLab CI we can do really powerful things when building, testing and deploying our applications.

You can find the source code for this example here:

0 Kommentarer

Lämna ett svar

E-postadressen publiceras inte. Obligatoriska fält är märkta *


Denna webbplats använder Akismet för att minska skräppost. Lär dig hur din kommentardata bearbetas.