Visit at Github Pages: http://reinier-vegter.github.io/Simple-Drupal-Docker-Toolset/
With this toolset, you can install docker and easily fire up any existing Drupal (or php) webroot in 2 seconds.
- drupal 6,7,8 (or basically any PHP app by disabling the drupal check, NO_DRUPAL_CHECK=1)
- SSL support
- PHP 5.4, 5.6 (default), 7.0
- Apache 2.2
- one MySQL container for all projects (data saved in your local home-folder).
- one Drupal container + hostname per project
- Solr 4 container for each project, data storage in project folder, and auto-using of search_api_solr config files.
- mailsink that collects al emails sent through sendmail (/tmp/d7-docker-mailsink on host)
- varnish out-of-the-box (See 'CUSTOM PROJECT CONFIGURATION')
- memcache
- custom mounts, dns entries, solr-config, local hostnames
- XHProf / XHGui
Simple Drupal Docker Toolset is sponsored and supported by Finalist B.V.
Clone git repository somewehere in local folder, or download archive package, and unpack.
git clone https://github.com/reinier-vegter/Simple-Drupal-Docker-Toolset.git ~/docker-drupal
- Install docker:
curl -sSL https://get.docker.com/ | sh
- Add yourself to docker group:
sudo usermod -aG docker [YOUR USER]
- Then, logout your system and login again
- Run
bin/install.sh
to symlink all needed scripts to your bin folder. - Give write access to yourself on hosts file:
sudo chown root:$(whoami) /etc/hosts
sudo chmod 664 /etc/hosts
From: https://docs.docker.com/installation/mac/
- Install toolbox from https://www.docker.com/toolbox
- Open Docker Quickstart Terminal and close when finished
- Open VirtualBox and assign more CPU's to the 'default' VM, as it will be quite slow by default (only 1 CPU)
- Add your user to 'wheel' group, in terminal (so the toolset can add hostname-entries to your hosts file):
sudo dseditgroup -o edit -a $(whoami) -t user wheel
- Give wheel-group write access to hosts file, in terminal:
sudo chmod 664 /etc/hosts
- Run the following command to symlink all needed scripts to your bin folder.
sudo bin/install.sh
Do a git pull to fetch the latest master-branch for this toolset.
Then, run bin/install.sh
again.
- d7-start : start drupal 7 container from project folder
- d7-stop : stop container for 'this' project
- d7-mysql-start : start mysql container (triggered by d7-start)
- d7-mysql-stop : stop mysql container
- d7-solr4-start : start solr4 container (triggered by d7-start)
- d7-solr4-stop : stop solr4 container
- d7-status : shows all docker containers (running and stopped)
- d7-stop-all : stops all drupal toolset related containers
- d7-update-images : Will pull updated images from repository.
You should run this every once in a while.
- d7-cleanup : Cleanup (stop + remove) all drupal 7 containers.
They are disposable, and usually removed immediately
when you stop a d7 container.
- d7-logs [num|all] : Tail all apache logs.
Argument sets number of lines to print, before following.
(Should be integer, or 'all')
Starts 'docker logs --tail=[num] -f [container]'
- d7-ssh [container (optional)] : Open shell (bash) in container. Defaults to container in current webroot folder.
- d7-drush [drush arguments] : This runs drush with supplied arguments, in the webroot, as web user.
You can alias this if you'd make this transparent on your system, by adding
alias drush="d7-drush" to your .bashrc file (~/.bashrc).
- d7-help : Show README
- d7-build-docker-image : Build / rebuild docker images. This replaces images that are downloaded from dockerhub.
To start your project, go to the project folder, and run 'd7-start' Note that settings.php must contain the mysql-host 'mysql-docker.dev', and that solr is reachable at localhost:8983 from each drupal container.
Building docker images is done the first time you use them ("d7-start"), and can take a while.
- mysql-docker.dev : Location of mysql server, reachable from host and container
- dockerhost : Location of your laptop / server. Reachable from container. To make it reachable from your laptop/server, just add '127.0.0.1 dockerhost' to /etc/hosts .
Custom docker stuff per project: Add file .d7-docker.conf to your project folder.
Be aware that any bash code in this file is actually executed
Example content of file:
# Add dependency container.
# Format: [container name]:[start-script/command]
# CUST_DEPENDENCIES=(
# "docker.mysql:${mydir}/d7-mysql-start.sh"
# "docker.solr4:${mydir}/d7-solr4-start.sh"
# )
#
# Add custom link between containers.
# Format: [dependency container name]:[hostname in 'this' container, mapped to dependency]
# CUST_LINK=(
# "docker.mysql:mysql-docker.dev"
# "docker.solr4:solr4-docker.dev"
# )
#
# Mount extra volumes in container.
# Format: [local folder]:[folder in container]
# CUST_VOL="/opt/simplesamlphp:/opt/simplesamlphp1"
#
# Give container extra hostnames.
# CUST_HOSTNAMES=(
# "dev.my-favorite-hostname.com"
# )
#
# Provide DNS (hosts-file) entries to container, so container can resolve it.
# For example usefull if you're having trouble to get docker to communicate through host-system VPN.
# CUST_DNS=(
# www.google-dns.com:8.8.4.4
# )
#
# Do not check if this is actually Drupal. Usable for 'other' php apps to be ran in
# a D7 container.
# NO_DRUPAL_CHECK=1
#
# Enable Varnish cache engine
# VARNISH_ENABLE=1
# Note: This will run Varnish on port 80 (so Drupal can talk to varnish on 127.0.0.1:80)
# and Apache on port 90.
# Note: To purge a page, let Drupal call URL's on varnish with the PURGE-method (like GET, but
# make it PURGE...). The purge and expire modules are a very useful combination to do this.
#
# Enable memcache daemon
# MEMCACHED_ENABLE=1
#
# Enable XHGui (Currently only for php 5.6).
# XHGUI_ENABLE=1
# Visit xhgui at /xhgui .
# Note that it takes some time to start mongodb.
#
# Set PHP version to use
# PHP_VERSION=5.4
# Supported versions: 5.4, 5.6, 7.0.
# Defaults to 5.6
#
# Custom per-project php.ini
# CUST_PHP_INI="/opt/web/flightcontrol/php.ini"
# Make sure to use an absolute path here!
#
# Custom location for Solr config files.
# Note that the toolset finds 'search_api_solr/solr-conf/4.x' automatically.
# Only use this if you use some other module, or schema files of your own.
# SOLR_CONF_OVERRIDES='sites/all/modules/contrib/search_api_solr/solr-conf/4.x'
#
XDebug is installed in the container. To use it with php-storm
- make sure to just enable the listener (no server config needed, defaults work fine) in order to start debugging.
- Generate the bookmarklets at https://www.jetbrains.com/phpstorm/marklets/ , to start/stop the debugger.
That's all...
To use XDebug profiler, just add a 'profiler' folder in your project. It will generate cachegrind files that you can open with KCacheGrind or any other tool. See http://www.xdebug.org/docs/profiler
Put your (extra) configuration in ~/.drupal_docker_toolset/mysql.cnf
and restart mysql
by executing d7-mysql-stop && d7-mysql-start
.
Example content:
[mysqld]
table_open_cache = 2000
innodb_buffer_pool_size = 3G