Development with Docker

WARNING: This is currently a Work in Progress

Instead of using Vagrant and building a Virtual Machine, developers should be able to use a Docker image to run everything.

Used components

To create a container image with the existing ansible configuration, the following components are used:

systemd replacement

Ansible configuring a Virutal Machine makes use of systemd to run required services. In a Docker container, there is no systemd available. To use the same ansible configuration, a systemd replacement is used.

https://github.com/gdraheim/docker-systemctl-replacement

Packer

To unify the build process over Docker, Vagrant and others, Packer is used to execute the actual build. This makes a Dockerfile unnecessary. Everything is defined in the packer.json file.

https://www.packer.io/

Make sure that at least version 1.3.5 of Packer is used.

Building the image

To build the image you need Docker and Packer installed. Building the image is not required for developers using Frontastic. Instead the idea is that Frontastic supplies the pre-build Docker images via Docker Hub or another registry. The developer then only needs Docker and uses Vagrant to spin up the container.

To create an image, run:

packer build --only=docker paas/automation/packer.json

in the project root. This executes ansible in a Docker environment, resulting in a suitable container image.

Running the container

vagrant up --provision --provider=docker

To get a shell in the container, run:

vagrant ssh

Debugging image builds with Packer

Add --on-error=ask to the call to Packer. Then Packer will stop on the first error and ask what to do. You can then manually examine the running container or Virtual Machine.