Drupal and Docker
Super powered drupal development
MACIEJ.LUKIANSKI@DROPTICA.COM
How to use docker to make drupal development
easier, quicker and more productible
In June
drupalcamp.pl
WWW.DROPTICA.COMDocker and Drupal
Problems of a dev team
● Multiple stacks
○ php 5.2 - 7.x
○ Many libraries & versions
○ Apache Solr 4.x to 6.x
○ Redis, Memcached
○ MongoDB, Nodejs, Elasticsearch
○ other
● How to:
○ Onboard developers quickly
○ Deploy and maintain integrity of environments:
■ dev,
■ test,
■ test_feature_7773
■ stage,
■ stage2,
■ ….
■ prod
○ Test the environments?
○ Propagate changes of environments between
team?
● Complex projects
○ Systems with APIs
○ Microservices
○ Legacy systems on outdated stacks
WWW.DROPTICA.COMDocker and Drupal
Possible solutions
● Use everyone’s local setups and hope it works
● Manually configure, upgrade, downgrade on each machine
● Virtualbox (with Puppet/Chef/Ansible)
● Vagrant
● Remote workspaces
WWW.DROPTICA.COMDocker and Drupal
● DOCKER - yay!
Our docker benefits
● Very few deployment surprises
○ No more “It worked on my machine”
WWW.DROPTICA.COMDocker and Drupal
● ~ 500 hours a year saved:
○ Setting up a project takes 10 minutes (3-5 commands)
○ Test/Stage environments in few minutes
○ No more differences between environments
○ Simplicity of services that took time to set up (solr, elasticsearch, mongo, node, postgres, other)
● We are looking beyond
○ cross functional expert teams
○ microservices
○ other technologies
● Stacks generally work (developers program rather than fight the architecture)
○ All config in code
How we do it?
WWW.DROPTICA.COMDocker and Drupal
● boilerplate images
● docker-console (custom script)
● docker-compose
Docker compose
● simple config file
● starting images often
enough
WWW.DROPTICA.COMDocker and Drupal
Once you get
the hang of it..
SSL for free with
jrcs/letsencrypt-nginx-proxy-companion
Separate images for crons
Backup as a service from a
separate image (create once,
use always)
Apache Solr quickly
available and configured
also locally
WWW.DROPTICA.COMDocker and Drupal
Boilerplate images
● droptica/apache-php https://hub.docker.com/r/droptica/apache-php
● droptica/php-fpm https://hub.docker.com/r/droptica/php-fpm
● droptica/php-developer https://hub.docker.com/r/droptica/php-developer
● droptica/codecept https://hub.docker.com/r/droptica/codecept
● droptica/mailcatcher https://hub.docker.com/r/droptica/mailcatcher
● droptica/postfix https://hub.docker.com/r/droptica/postfix
● droptica/jmeter https://hub.docker.com/r/droptica/jmeter
● and more...
WWW.DROPTICA.COMDocker and Drupal
How do I develop?
Where is drush?
Where is mysqldump?
Where is a sass compiler?
And all other development tools?
Apache &
PHP
mysql
Apache
Solr
mailer backup
mongodb
WWW.DROPTICA.COMDocker and Drupal
docker-compose.yml
php-developer & docker-console
Apache &
PHP
mysql
php-developer
(developer container)
sample commands:
dcon drush uli
dcon drush cc all
dcon shell -s
Apache
Solr
mailer backup
other
1. drush
2. Sass (ruby gems etc)
3. npm, bower, fabric,
4. Other tools
gives you a server-like feeling
WWW.DROPTICA.COMDocker and Drupal
● understands docker-compose.yml
● Multiple pre-built commands
● Building workflows like lego
● Custom commands (in python)
Docker console ~$ pip install docker-console
An additional application which helps to
automate workflow using the
php-developer image
WWW.DROPTICA.COMDocker and Drupal
DEMO
WWW.DROPTICA.COMDocker and Drupal
Heavy equipment dealer website
WWW.DROPTICA.COMDocker and Drupal
● Drupal
● Redis for cache
● Search with solr
● Mongodb with some data from
other system
Demo dealer dev environment
Apache & PHP
(to serve drupal)
+ php libraries
for mongodb
mysql
Apache
Solr
mongodb
WWW.DROPTICA.COMDocker and Drupal
Admin panel
for mongo
(mogo-express)
redis
docker-compose.ym
l
WWW.DROPTICA.COMDocker and Drupal
web:
build: ./docker/custom_images/custom-web
volumes:
- ./docker/custom_config/apache2.conf:/etc/apache2/apache2.conf:ro
- ./docker/custom_config/default-vhost.conf:/etc/apache2/sites-enabled/000-default.conf
- ./app/web:/var/www/web
links:
- mysql:mysql
- mongo:mongo
- solr:solr
environment:
VIRTUAL_HOST: ddemo.dev,www.ddemo.dev
mysql:
image: mysql:5.6
volumes:
- ./app_data/database:/var/lib/mysql
- ./docker/custom_config/my.cnf:/etc/mysql/conf.d/custom.cnf:ro
solr:
image: solr:6
volumes:
- ./app_conf/solr_conf/ddemo_search/conf:/opt/solr/server/solr/ddemo_search/conf
- ./app_conf/solr_conf/ddemo_search/core.properties:/opt/solr/server/solr/ddemo_search/core.properties
- ./app_data/solr_data/ddemo_search:/opt/solr/server/solr/ddemo_search/data
ports:
- 8983:8983
mongo:
image: mongo
volumes:
- ./app_data/mongodb:/data/db
mongo-express:
image: mongo-express
links:
- mongo:mongo
ports:
- 8081:8081
redis:
image: redis
This is all it takes
New developer comes along
WWW.DROPTICA.COMDocker and Drupal
1. git pull git@git-url-to-the-repository
2. cd repository
3. docker-console up
Apache & PHP
+ php libraries for
mongodb
mysql
Apache Solr
mongodb
Admin
panel for
mongo
and presto
Redis
To import db, composer install, run updates etc:
1. fab get-dbases
2. Docker-console build Project set up and working
But where is the demo ??
WWW.DROPTICA.COMDocker and Drupal
This is too simple..
WWW.DROPTICA.COMDocker and Drupal
Show me more complex
Nginx to serve
Drupal
cron daily
cron alerts
cron html
printouts
Mailer
XML generator
Rabbitmq
tests
PHP
cron search api
cron emails
daily
DRUPAL
codebase
blackfire
cron emails
weekly
Nginx to serve
xml extracts
WWW.DROPTICA.COMDocker and Drupal
....
14 cron
containers
…..
Mailcatcher
Files
Mysql
Redis
Solr
Nginx for
drupal
cron daily
cron alerts
cron html
printouts
cron backup
Mailer
XML
generator
Rabbitmq
tests
cache warmerPHP
cron search
api
cron emails
daily
DRUPAL
codebase
blackfire
cron emails
weekly
AWS S3
Nginx for
xml
WWW.DROPTICA.COMDocker and Drupal
....
14 cron
containers
…..
Files
AWS
RDS
Redis
Solr
Mailchimp
php:
build: ./docker/Dockerfiles/custom-php
links:
- mysql:mysql
- solr:solr
- redis:redis
- mailcatcher:mailcatcher
- rabbit:rabbit
- blackfire:blackfire
php:
restart: always
build: ./docker/Dockerfiles/custom-php-prod
links:
- blackfire:blackfire
extra_hosts:
- "solr:${SOLR_HOST}"
- "mailcatcher:${MAILER_HOTS}"
- "rabbit:${RABBIT_HOST}"
dev
prod
cron daily
cron backup
XML
generator
PHP
MailerRabbitmq
cron emails
weekly
WWW.DROPTICA.COMDocker and Drupal
....
14 cron
containers
…..
AWS
RDS
Redi
s
Solr
Nginx PHP
Nginx
loadbalancer
cache warmer
Files
tests
Web
browsers
Additional Benefits
● Easy to see what environment consist of (all is in code)
● A move towards SOA (we do not care how solr or rabbitmq is set up)
● Great step towards microservices
WWW.DROPTICA.COMDocker and Drupal
● Upgrades of stack are a breeze (php5 -> php7 is a one line)
● Easier to explore technologies - “there is an image for that”
● don’t hold data in containers (map volumes or use docker volumes)
● don’t hold multiple services in one container
● do use code for config (Dockerfile, docker-compose)
Dos and don’ts
WWW.DROPTICA.COMDocker and Drupal
● github.com/droptica/docker-tutorial
How to start
WWW.DROPTICA.COMDocker and Drupal
● Use docker for services
solr:
image: solr.6
ports:
- 8983:8983
redis:
image: redis
● www.droptica.com/blog
Thank you
Imię i Nazwisko autora
Maciej Lukianski
maciej.lukianski@droptica.com
@MaciejLukianski
Contact details:
WWW.DROPTICA.COM

Super powered Drupal development with docker

  • 1.
    Drupal and Docker Superpowered drupal development MACIEJ.LUKIANSKI@DROPTICA.COM How to use docker to make drupal development easier, quicker and more productible
  • 2.
  • 3.
    Problems of adev team ● Multiple stacks ○ php 5.2 - 7.x ○ Many libraries & versions ○ Apache Solr 4.x to 6.x ○ Redis, Memcached ○ MongoDB, Nodejs, Elasticsearch ○ other ● How to: ○ Onboard developers quickly ○ Deploy and maintain integrity of environments: ■ dev, ■ test, ■ test_feature_7773 ■ stage, ■ stage2, ■ …. ■ prod ○ Test the environments? ○ Propagate changes of environments between team? ● Complex projects ○ Systems with APIs ○ Microservices ○ Legacy systems on outdated stacks WWW.DROPTICA.COMDocker and Drupal
  • 4.
    Possible solutions ● Useeveryone’s local setups and hope it works ● Manually configure, upgrade, downgrade on each machine ● Virtualbox (with Puppet/Chef/Ansible) ● Vagrant ● Remote workspaces WWW.DROPTICA.COMDocker and Drupal ● DOCKER - yay!
  • 5.
    Our docker benefits ●Very few deployment surprises ○ No more “It worked on my machine” WWW.DROPTICA.COMDocker and Drupal ● ~ 500 hours a year saved: ○ Setting up a project takes 10 minutes (3-5 commands) ○ Test/Stage environments in few minutes ○ No more differences between environments ○ Simplicity of services that took time to set up (solr, elasticsearch, mongo, node, postgres, other) ● We are looking beyond ○ cross functional expert teams ○ microservices ○ other technologies ● Stacks generally work (developers program rather than fight the architecture) ○ All config in code
  • 6.
    How we doit? WWW.DROPTICA.COMDocker and Drupal ● boilerplate images ● docker-console (custom script) ● docker-compose
  • 7.
    Docker compose ● simpleconfig file ● starting images often enough WWW.DROPTICA.COMDocker and Drupal
  • 8.
    Once you get thehang of it.. SSL for free with jrcs/letsencrypt-nginx-proxy-companion Separate images for crons Backup as a service from a separate image (create once, use always) Apache Solr quickly available and configured also locally WWW.DROPTICA.COMDocker and Drupal
  • 9.
    Boilerplate images ● droptica/apache-phphttps://hub.docker.com/r/droptica/apache-php ● droptica/php-fpm https://hub.docker.com/r/droptica/php-fpm ● droptica/php-developer https://hub.docker.com/r/droptica/php-developer ● droptica/codecept https://hub.docker.com/r/droptica/codecept ● droptica/mailcatcher https://hub.docker.com/r/droptica/mailcatcher ● droptica/postfix https://hub.docker.com/r/droptica/postfix ● droptica/jmeter https://hub.docker.com/r/droptica/jmeter ● and more... WWW.DROPTICA.COMDocker and Drupal
  • 10.
    How do Idevelop? Where is drush? Where is mysqldump? Where is a sass compiler? And all other development tools? Apache & PHP mysql Apache Solr mailer backup mongodb WWW.DROPTICA.COMDocker and Drupal docker-compose.yml
  • 11.
    php-developer & docker-console Apache& PHP mysql php-developer (developer container) sample commands: dcon drush uli dcon drush cc all dcon shell -s Apache Solr mailer backup other 1. drush 2. Sass (ruby gems etc) 3. npm, bower, fabric, 4. Other tools gives you a server-like feeling WWW.DROPTICA.COMDocker and Drupal
  • 12.
    ● understands docker-compose.yml ●Multiple pre-built commands ● Building workflows like lego ● Custom commands (in python) Docker console ~$ pip install docker-console An additional application which helps to automate workflow using the php-developer image WWW.DROPTICA.COMDocker and Drupal
  • 13.
  • 14.
    Heavy equipment dealerwebsite WWW.DROPTICA.COMDocker and Drupal ● Drupal ● Redis for cache ● Search with solr ● Mongodb with some data from other system
  • 15.
    Demo dealer devenvironment Apache & PHP (to serve drupal) + php libraries for mongodb mysql Apache Solr mongodb WWW.DROPTICA.COMDocker and Drupal Admin panel for mongo (mogo-express) redis
  • 16.
    docker-compose.ym l WWW.DROPTICA.COMDocker and Drupal web: build:./docker/custom_images/custom-web volumes: - ./docker/custom_config/apache2.conf:/etc/apache2/apache2.conf:ro - ./docker/custom_config/default-vhost.conf:/etc/apache2/sites-enabled/000-default.conf - ./app/web:/var/www/web links: - mysql:mysql - mongo:mongo - solr:solr environment: VIRTUAL_HOST: ddemo.dev,www.ddemo.dev mysql: image: mysql:5.6 volumes: - ./app_data/database:/var/lib/mysql - ./docker/custom_config/my.cnf:/etc/mysql/conf.d/custom.cnf:ro solr: image: solr:6 volumes: - ./app_conf/solr_conf/ddemo_search/conf:/opt/solr/server/solr/ddemo_search/conf - ./app_conf/solr_conf/ddemo_search/core.properties:/opt/solr/server/solr/ddemo_search/core.properties - ./app_data/solr_data/ddemo_search:/opt/solr/server/solr/ddemo_search/data ports: - 8983:8983 mongo: image: mongo volumes: - ./app_data/mongodb:/data/db mongo-express: image: mongo-express links: - mongo:mongo ports: - 8081:8081 redis: image: redis This is all it takes
  • 17.
    New developer comesalong WWW.DROPTICA.COMDocker and Drupal 1. git pull git@git-url-to-the-repository 2. cd repository 3. docker-console up Apache & PHP + php libraries for mongodb mysql Apache Solr mongodb Admin panel for mongo and presto Redis To import db, composer install, run updates etc: 1. fab get-dbases 2. Docker-console build Project set up and working
  • 18.
    But where isthe demo ?? WWW.DROPTICA.COMDocker and Drupal
  • 19.
    This is toosimple.. WWW.DROPTICA.COMDocker and Drupal Show me more complex
  • 20.
    Nginx to serve Drupal crondaily cron alerts cron html printouts Mailer XML generator Rabbitmq tests PHP cron search api cron emails daily DRUPAL codebase blackfire cron emails weekly Nginx to serve xml extracts WWW.DROPTICA.COMDocker and Drupal .... 14 cron containers ….. Mailcatcher Files Mysql Redis Solr
  • 21.
    Nginx for drupal cron daily cronalerts cron html printouts cron backup Mailer XML generator Rabbitmq tests cache warmerPHP cron search api cron emails daily DRUPAL codebase blackfire cron emails weekly AWS S3 Nginx for xml WWW.DROPTICA.COMDocker and Drupal .... 14 cron containers ….. Files AWS RDS Redis Solr Mailchimp php: build: ./docker/Dockerfiles/custom-php links: - mysql:mysql - solr:solr - redis:redis - mailcatcher:mailcatcher - rabbit:rabbit - blackfire:blackfire php: restart: always build: ./docker/Dockerfiles/custom-php-prod links: - blackfire:blackfire extra_hosts: - "solr:${SOLR_HOST}" - "mailcatcher:${MAILER_HOTS}" - "rabbit:${RABBIT_HOST}" dev prod
  • 22.
    cron daily cron backup XML generator PHP MailerRabbitmq cronemails weekly WWW.DROPTICA.COMDocker and Drupal .... 14 cron containers ….. AWS RDS Redi s Solr Nginx PHP Nginx loadbalancer cache warmer Files tests Web browsers
  • 23.
    Additional Benefits ● Easyto see what environment consist of (all is in code) ● A move towards SOA (we do not care how solr or rabbitmq is set up) ● Great step towards microservices WWW.DROPTICA.COMDocker and Drupal ● Upgrades of stack are a breeze (php5 -> php7 is a one line) ● Easier to explore technologies - “there is an image for that”
  • 24.
    ● don’t holddata in containers (map volumes or use docker volumes) ● don’t hold multiple services in one container ● do use code for config (Dockerfile, docker-compose) Dos and don’ts WWW.DROPTICA.COMDocker and Drupal
  • 25.
    ● github.com/droptica/docker-tutorial How tostart WWW.DROPTICA.COMDocker and Drupal ● Use docker for services solr: image: solr.6 ports: - 8983:8983 redis: image: redis ● www.droptica.com/blog
  • 26.
    Thank you Imię iNazwisko autora Maciej Lukianski maciej.lukianski@droptica.com @MaciejLukianski Contact details: WWW.DROPTICA.COM