Awesome Open Source
Awesome Open Source
Sponsorship

drucker Logo

drucker: Drupal + Docker

Build Status

drucker demo

Introduction

drucker is an opinionated Docker-based Drupal stack managed by Ansible for orchestration. It automates creating Debian containers on which it will deploy a common web stack to run Drupal applications.

drucker runs on 5 containers:

  • drucker_mirror (203.0.113.50): APT mirror. Listens on port 3142. Allows for speedy reinstallation.
  • drucker_edge (203.0.113.2): Varnish listens on port 80 and sends traffic to the Apache backend via nginx on port 8080).
  • drucker_web (203.0.113.10): Apache listens on port 80 and receives traffic from nginx.
  • drucker_db (203.0.113.12): MySQL listens on port 3306 and allows the stack to act as a multi-tier environment.
  • drucker_search (203.0.113.13): Apache Solr listens on port 8983.

Requirements

Software

You need to have both Docker and Ansible installed on your machine. Check with the below commands:

$ docker version
Docker version 17.09.0-ce, build afdb6d4
$ ansible --version
ansible 2.4.1.0

Important: Ansible 2.4 or later is required.

drucker is written in Python and requires several dependencies to run correctly. Install with:

$ pip3 install pycodestyle pylint colorful click --user

Disk space

You need to have approximately 6GB available.

SSH

You also need to generate a SSH key if you don't have one already.

Technology

drucker ships with the following software stack:

Software Version Source
Debian 9 (Stretch) debian:stretch (Docker Hub)
Varnish 5.0.0 or higher APT
nginx 1.10.3 or higher APT
Apache 2.4.25 or higher APT
MariaDB 10.1.26 or higher APT
memcached 3.1.3 APT, via ppa:ondrej/php
mcstat 1.1.0 webbj74/mcstat (Github)
phpMyAdmin 4.8.5 phpMyAdmin (official site)
adminer 4.7.1 vrana/adminer (Github)
PHP-FPM 7.1 or 7.2 APT, via ppa:ondrej/php
APCu 5.1.17 or higher APT, via php-apcu (ppa:ondrej/php)
Coder 8.2.11 drupal/coder (Packagist)
Code Sniffer 2.6.1 squizlabs/PHP_CodeSniffer (Github)
PHP-CS-Fixer 2.14.3 FriendsOfPHP/PHP-CS-Fixer (Github)
phpmd 2.6.0 PHPMD (official site)
phpstan 0.11.2 or higher mglaman/phpstan-drupal (Github)
PECL YAML 2.0.4 php/pecl-file_formats-yaml (Github)
LibYAML 0.2.2 PyYAML (official site)
Xdebug 2.7.2 Xdebug (official site)
Tideways Profiler 4.1.7 tideways/php-profiler-extension (Github)
phantomjs 2.1.1 ariya/phantomjs (Bitbucket)
Drupal 8.7.x Drupal (official site)
Drush ^9.0 Drush (Packagist)
Drush Launcher 0.6.0 Drush Launcher (Github)
Drupal Console ~1.0 hechoendrupal/drupal-console-launcher (Github)
Composer 1.8.5 Composer (official site)
Apache Solr 7.6.0 Solr (official site)
OpenJDK 1.8.0_121 or higher APT, via debian-backports
bash-git-prompt 2.7.1 magicmonty/bash-git-prompt (Github)

Installation

Configuring the hosts file

Add the below entries in your /etc/hosts file:

203.0.113.2    drucker.local phpmyadmin.local adminer.local lightning.local blt.local
203.0.113.13   search.local
203.0.113.50   mirror.local

This will ensure you can access:

  • drucker.local: Drupal 8
  • phpmyadmin.local: phpMyAdmin (MySQL/MariaDB database management tool)
  • adminer.local: adminer (Database management tool in a single file)
  • search.local:8983/solr/#/: Apache Solr's dashboard

Recommended: add the below bash alias entry in your .bashrc or .bash_aliases file:

alias drucker='path/to/drucker/drucker'

Source the file (or log out and log back in) to use the alias immediately. E.g.:

$ source ~/.bashrc

This will allow you to invoke drucker from anywhere on your system.

Creating or configuring the config file

Add the below in your config file (under $HOME/.ssh) or create the file if it doesn't exist.

Host 203.0.113.99 203.0.113.2 203.0.113.10 203.0.113.12 203.0.113.13 203.0.113.50
  StrictHostKeyChecking no
  UserKnownHostsFile=/dev/null
  LogLevel=error

This will prevent SSH strict host key checking from getting in the way, since drucker is for development purposes only.

Usage

Simply run drucker if you have a bash alias, or invoke the drucker script directly.

$ ./path/to/drucker
Enter path to SSH public key [/home/<username>/.ssh/id_rsa.pub]:
Where should we store drucker sites locally? [/var/www/html]:
Where should we store drucker databases locally? [/var/lib/mysql]:

On the first run, drucker will prompt you with the path to your SSH public key, but will also try to map the drucker sites and databases paths to local directories of your choice, so that containers are made disposable by still preserving your data. You can override the default paths and this information will be stored in the config file going forward.

To prevent Git from prompting you with changes to the config file, you can exclude it from the Git tracking entirely with:

$ git update-index --assume-unchanged config

Should you want to stop doing so, just type:

$ git update-index --no-assume-unchanged config

Passwords:

  • drucker user password in containers: drucker
  • MySQL credentials: root/root
  • Drupal credentials: admin/admin

For more advanced drucker usage, you can pass several CLI parameters:

$ drucker -h
usage: drucker [-h] [--drupal] [--lightning] [--blt] [--reinstall] [--dev]
[--prod] [--import] [--delete] [--start] [--stop] [--restart]
[--health] [--php7.3] [--php7.2] [--php7.1] [--list] [--tests]
[--version]
[app]
positional arguments:
app          Targets an arbitrary app
optional arguments:
-h, --help   show this help message and exit
--drupal     Spins up a ready-to-use Drupal install
--lightning  Spins up a ready-to-use Lightning install
--blt        Spins up a ready-to-use BLT build
--reinstall  Reinstalls Drupal or the currently installed distribution
--dev        Configures the app for development use
--prod       Configures the app for production use
--import     Imports an app from the web container's import directory
--delete     Deletes an arbitrary docroot
--start      Starts all containers
--stop       Stops all containers
--restart    Restarts all containers
--health     Runs a service healthcheck
--php7.3     Sets the PHP version to 7.3
--php7.2     Sets the PHP version to 7.2
--php7.1     Sets the PHP version to 7.1
--list       Lists all deployed apps
--tests      Runs the Ansible test suite
--version    Returns the drucker version

Notes:

  • Warning: when running automated tests, 'twig_debug' should be set to FALSE.
  • The app:import parameter is a special beast. Please read more about it in the wiki.

Working with containers

Get into a container

The below command will get you in as the privileged user drucker

$ docker exec -u drucker -it <container_name> bash

To get in as root instead, type:

$ docker exec -it <container_name> bash

As root, if you wish to log in as the drucker username again (which is recommended and is a sudoer), simply type:

$ su drucker

Delete a container

$ docker rm -f <container_name>

When you run drucker, missing containers will be spun up from existing images.

Delete an image

$ docker rmi <drucker:image>

When you run drucker, missing images will be built.

Troubleshooting

If for any reason an image would fail to be built or a container would be giving you troubles, go ahead and delete the offender! Running drucker will always have your back and rebuild missing images and containers.

For more assistance, see Troubleshooting drucker or file an issue.


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
shell (9,329
docker (2,530
cli (1,575
ansible (384
orchestration (72
drupal (68
lamp (24

Find Open Source By Browsing 7,000 Topics Across 59 Categories