Tools we use at work - part 2 - Docker

In the first article about the tools we use, we described our project management and communication tools. Today we will show you how we manage development environments.

Local copy

In Droptica each programmer works on a local copy of the website. Each task is completed and committed to a separate Git branch and pushed to a remote repository.

Our standard desktop system is Ubuntu therefore for a long time we got away with just installing Apache, Mysql and PHP locally. Most of the time this is enough to set up and successfully work on a project. As time goes by however, projects we work on get more and more complex and need additional software and services to work (eg. Apache Solr, Elasticsearch, Memcache, Redis, ffmpeg converted etc). PHP7 came out and with it the need to run some of the projects on PHP7 while some are still sitting on PHP5. All this made working on multiple projects at the same time more difficult.

Docker helped us solve this problem. In a nutshell docker enables you to run services and apps in isolated containers. For example you can simultaneously run Apache with PHP7 and with PHP5 in 2 containers the same project or have 2 different versions of Mysql. Each project has it's own environment encapsulated in containers and a developer can have multiple projects running locally without interference.

As great as Docker is however it is not too user friendly. If is operated from the commandline and requires you to type long, difficult to structure commands to set up more complicated environments. To help with that we use docker-compose which allows you to declare containers and their setup in a YML file.

That was already great but we still encountered drawbacks. It's great to set up Apache, Mysql and PHP in linked containers, but how do you then get to it and work with it? There is no drush, there may be other tools you might want to use like fabric, compass, gulp and the likes, which should not really be installed in your production images. To manage this we created Docker-Drupal ( https://github.com/droptica/docker-drupal) - an application written in python which helps us with development. After installing it you have access to a docker-drupal command. This command uses our 'development' docker image (https://hub.docker.com/r/droptica/drupal-dev/) which attaches itself to the environment and can execute commands for you. This image by default has drush installed and a few more elements. Depending on a project we often add additional elements. The docker-drupal app is easily extensible. You can add your own commands and actions. For example you could write a function which will import 2 databases, execute a migration script, enable a few modules and rebuild search API indexes.

Since introduction of docker-drupal, starting on a new project in Droptica usually requires cloning the repository and running "drocker-drupal up && drocker-drupal build" and after a few minutes a new fully working website is available for the developer in an environment identical to the one in production with all the services in the same versions.

Docker-drupal was written by our team members Tomasz Wodzikowski and Damian Sikora. If you used Drocker-drupal we would love to hear from you.

Get blog updates in your inbox!

Sign up for out newsletter and get e-mails of stories like this.

Your name

Your e-mail address

By Subscribing to our newsletter you agree for terms and conditions

By sending the form You consent to process Your personal data by DROPTICA Sp. z o.o. based in Wrocław ul. Duńska 9 and to entrust data to subjects cooperating with DROPTICA Sp. z o.o. for processing purposes. Submission of data is voluntary, however, lack of consent for personal data processing makes it impossible to answer your question. You have the right to access your personal data and correct it.