RajaRamesh / drucker

drucker: Drupal + Docker - Spin up Drupal, Lightning, Reservoir or BLT in seconds.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

drucker Logo

drucker: Drupal + Docker

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_reverse_proxy (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.

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.0.4 APT, via ppa:ondrej/php
mcstat 1.1.0 webbj74/mcstat (Github)
phpMyAdmin 4.7.9 phpMyAdmin (official site)
adminer 4.6.2 vrana/adminer (Github)
PHP-FPM 7.1 or 7.2 APT, via ppa:ondrej/php
APCu 5.1.8 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.10.5 FriendsOfPHP/PHP-CS-Fixer (Github)
phpmd 2.6.0 PHPMD (official site)
PECL uploadprogress master php/pecl-php-uploadprogress (Github)
PECL YAML 2.0.0 php/pecl-file_formats-yaml (Github)
LibYAML 0.1.7 PyYAML (official site)
Xdebug 2.6.0 Xdebug (official site)
Tideways Profiler 4.1.5 tideways/php-profiler-extension (Github)
phantomjs 2.1.1 ariya/phantomjs (Bitbucket)
Drupal 8.6.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.6.2 Composer (official site)
Apache Solr 7.2.1 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 reservoir.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.sh'

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.sh script directly.

$ ./path/to/drucker.sh
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 help
drucker version dev:ba964ca

Usage:
  drucker [command] [site,...] [git_tag]

  The [site,...] argument is only valid for the following commands:
    app:[drupal,lightning,reservoir,blt]
    app:[delete,import,dev,prod]

  The [git_tag] argument is only valid for the app:drupal command.

 containers
  containers:health   Runs a service healthcheck
  containers:start    Starts all drucker containers
  containers:stop     Stops all drucker containers
  containers:restart  Restarts all drucker containers

 app
  app:list            Lists all deployed apps
  app:drupal          Spins up a ready-to-use Drupal install
  app:lightning       Spins up a ready-to-use Lightning install
  app:reservoir       Spins up a ready-to-use Reservoir install
  app:blt             Spins up a ready-to-use BLT build
  app:delete          Deletes an arbitrary docroot
  app:import          Imports an app from the web container's import directory
  app:dev             Prepare app for development work with no caching and helper modules enabled.
  app:prod            Opinionated setup with all known performance best practices enabled.

 util
  php:[version]       Sets the PHP version to 7.1 or 7.2
  version             Returns the drucker version
  tests               Runs the Ansible test suite
  help                Displays valid drucker commands and their use

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.

About

drucker: Drupal + Docker - Spin up Drupal, Lightning, Reservoir or BLT in seconds.

License:GNU General Public License v3.0


Languages

Language:Shell 98.8%Language:VCL 1.2%