How we build our Magento 2 environment using Docker and continuous integration

Choosing a suitable Docker image

How to dress in layers

Cronjobs in Docker

So we broke our own rule.

The source of it all: Magento

FROM sensson/magento2
COPY src/cron /etc/cron.d/magento2
COPY src/ /var/www/html/

Source control

|-- Dockerfile
`-- src
|-- app
| `-- etc
| |-- config.php
| `-- env.php
|-- composer.json
`-- cron

Deployment configuration

return array(
'install' => array('date' => 'Tue, 21 Nov 2017 15:06:38 +0000',),
'cache_types' => array(
'config' => 1,
'layout' => 1,

Continuous integration and how it fitted in our development process from test to production



But it didn’t work. Our builds had PHP syntax errors. We used Docker. Why did Docker fail us?

- apk add php7 php7-curl php7-openssl php7-json php7-phar php7-dom php7-iconv php7-mbstring php7-zlib php7-ctype php7-gd php7-simplexml php7-mcrypt php7-intl php7-xsl php7-zip php7-pdo_mysql php7-soap php7-xmlwriter php7-tokenizer php7-xml && curl -sS | php -- --install-dir=/usr/bin --filename=composer
"config": {
"platform": {
"php": "7.0.23"


Integration tests

docker-compose build
docker-compose up -d
echo "Waiting on the environment to come online"
sleep 240
docker logs magento-frontend || true
docker run --rm --net host appropriate/curl -I -s localhost:8080 | \
grep '200 OK'
docker-compose down

Closing words

Open source




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Using Velo by Wix to Integrate 3rd-Party API Data

Build your own music streaming service with Amazon Alexa

Ballast Token, Platform, Ecosystem, why HODL, and Timeline

How to tackle the infamous CKA exam

Oh, CRUD! Give it a REST(ful)

Minikube — Docker Desktop Alternative

How to fix “Stopping Apache…fail. apachectl returned 1.” on XAMPP Linux

5 simple steps for code refactoring

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


More from Medium

Deploy WordPress on Kubernetes

Fundamentals of OpenIdConnect(OIDC)

Memcache Testing and Proxying

Custom Actions in Botframework Composer with Node.JS (Part 1)