Docker scaffolding for Drupal 8
This script is intended for one-time, initial scaffolding of a new Drupal 8 project,
which would then be self-contained. It uses a composer.json
file derived from drupal-project
to pull in Drupal core, and provides additional helpful Docker-focused functionality.
The drupal-project composer.json
file and helper scripts can then be used to manage
core updates, contrib modules and more. Drupal 8, with its robust exportable configuration
file management and composer integration, is uniquely suited for containerized development.
composer create-project bradjonesllc/docker-drupal:master project-dir --no-interaction
…Will install into a new directory named project-dir
.
docker-compose up
http://localhost:8082
docker-compose exec web drush uli
(See below for shortcut options)Your new Drupal 8 site comes with a number of helper scripts and config files that speed development in a containerized environment and production deployment.
Dockerfile
that includes all required PHP extensions for Drupal 8settings.php
, settings.local.php
and development.services.yml
files.settings.local.php
and development.services.yml
ddrush
, for executing drush inside the
web container, with a starter global /etc/drush/drushrc.php
file.dbash
, a shortcut for getting a bash shell inside the web container (as www-data).envrc
file, for use with direnv, that:
vendor/bin
directory into the PATH.ddrush
helper script.dockerignore
excludes VCS and uploaded files. Docker runs composer install
inside the container on build, though if your development environment includes
many of those files, having them copied into the container saves some time on
build. See Development Workflow, below.STDOUT
; this is useful if you wish to
aggregate your Docker container logs or integrate with an external log service
such as Logentries.rsyslog.json.conf
file, which will format log output in JSON format;
this expects JSON output directly from Drupal; consider using a module like
Syslog JSONSITE_URL
environment variable, so Drupal constructs
appropriate self-referential URLs during cron.Issues and pull requests welcome; Both Drupal 8 and Docker are relatively new and fast-moving projects. There doesn’t appear to be many other comprehensive starterkits for Docker and Drupal, so this is my effort at helping others avoid my steep learning curve on this front.
© 2016, Brad Jones LLC. Licensed under GPL 2.