How to Set up an Automatic Docker Staging - Mini Guide

Photo of Marcin Siepetowski

Marcin Siepetowski

Aug 23, 2016 • 2 min read

Dynamic staging or integration uses the combined power of Docker and Docker Compose which is a tool that lets you easily configure and link containers with a single YAML file as well as build containers with linked services, such as databases, redis, etc.

Take a look at how to set up an automatic Docker staging and how we do it at Netguru.

How Does It Work At Netguru?

Each time a pull request is created, GitHub sends a webhook to our specially created app - Heaven - which takes the latest Git revision of that specific branch along with the pull request number and “builds” the app using said Docker Compose configuration, which is later accessible by the host specified in docker-compose.yml.

A sample Docker Compose configuration might look like this:


We define what should be built in line 2 and provide the Dockerfile in line 3.

We have the section links which does what it says - it links the containers from lines 12 and 14, which are built on given images and which are later accessible from within our “main” application container. We can easily set up the environment variables for our container and other options such as cpu_quota or hostname.

As long as our pull request is opened, every new commit to that PR rebuilds the container with the new code, so when we access the host we provided on line 8 of the configuration file, we should see our “dynamically” setup application.

When developing an application using pull requests, every ticket has its own branch, which means that every ticket has its own pull request. This gives us the ability to test changes that are only within the scope of our ticket, and we don’t have to worry about other people's changes that might break the application. It also has a downside - on the one hand, every dynamic staging has its own database container that we can break, but - on the other hand, the data between normal and dynamic staging isn’t linked, which means we have to specify the seeds for the initial database state that we need.

What do you think about this solution? Let me know in the comments below!

Photo of Marcin Siepetowski

More posts by this author

Marcin Siepetowski

Marcin has been a computer enthusiast since his early childhood and the discovery of Rails turned...
How to build products fast?  We've just answered the question in our Digital Acceleration Editorial  Sign up to get access

We're Netguru!

At Netguru we specialize in designing, building, shipping and scaling beautiful, usable products with blazing-fast efficiency
Let's talk business!

Trusted by:

  • Vector-5
  • Babbel logo
  • Merc logo
  • Ikea logo
  • Volkswagen logo
  • UBS_Home