- Requirements
- Description
- Quick demo (Ubuntu)
- Installation and configuration
- Daily usage
- Reset the stack
- Linux helpers
- Upgrade
- Suggested tools
- Troubleshooting
Full Linux support. Tested daily on Ubuntu 16+.
Windows support is very, very limited due to Docker for Windows permissions problems and no privileged support :(
Mac support is very limited due to the fact that I don't have a Mac!
Recommended
Based mostly on Docker official images and lightweight Alpine Linux to ease maintenance and size.
This stack is meant to be used as a single Drupal 8 project only with quick setup, run and destroy workflow.
The purpose is to give flexibility in management, try to rely as much as possible on official tools to avoid any new custom patterns.
This stack is not a one line command but more for users with a good dev-op level and knowledge on each technology used.
See other great project for a Docker based development
Every service is optional as declared in the yml file.
- Apache
- Nginx
- Php 7.3 / 7.4 fpm with Xdebug
- MariaDB
- PostgreSQL
- Memcache
- Redis
- Mailhog
- Solr
- Dashboard: a very minimal docker dashboard for this stack
- Portainer: (Optional) a full Docker dashboard / manager
Get this project
wget https://gitlab.com/mog33/docker-compose-drupal/-/archive/master/docker-compose-drupal-master.tar.gz
tar -xzf docker-compose-drupal-master.tar.gz
cd docker-compose-drupal-master
Install this stack with minimal services, download and install Drupal 8 with profile Demo Umami
make demo
Grab this project
wget https://gitlab.com/mog33/docker-compose-drupal/-/archive/master/docker-compose-drupal-master.tar.gz
tar -xzf docker-compose-drupal-master.tar.gz
cd docker-compose-drupal-master
Create your docker compose file from template
cp docker-compose.tpl.yml docker-compose.yml
cp default.env .env
Optional: Edit configuration
Recommended on Unix add your local uid/gid.
vi .env
Optional: Customize the stack
Choose a database, remove or add services, add your composer cache folder if needed on service php
.
Do not touch for a default quick stack.
vi docker-compose.yml
Check the yml file and fix if there is an error message
docker-compose config
For an existing Drupal 8 project, copy it here in a folder named drupal
.
So you have your composer.json file in drupal\composer.json
Note that based on Composer template web root must be under drupal/web
folder. If not you need to adapt Apache vhost config from
config/apache/vhost.conf
cp -r _YOUR_DRUPAL_ drupal
For MySQL, copy your database dump uncompressed in ./database/mysql-init/*.sql
, it
will be automatically imported on the first launch of the stack.
For PostgresSQL, copy your database dump uncompressed in ./database/pgsql-init/*.pg_dump
, it
will be automatically imported on the first launch of the stack.
If you want to manually import your database with adminer or included helper scripts with _Linux_you can skip this step.
docker-compose up --build -d
Wait and check the import of your database dump with (change mysql to pgsql if needed)
docker-compose logs mysql
Setup a new Drupal 8 based on a Composer project.
Based on Drupal 8 template, include Drush and Drupal console, using Composer locally:
composer create-project drupal-composer/drupal-project:8.x-dev drupal --stability dev --no-interaction
docker-compose up --build -d
To use PostGreSQL change mysql to pgsql
You can replace standard by an other profile as minimal or demo_umami for Drupal 8.6+.
docker exec -it -u apache dcd-php /var/www/localhost/vendor/bin/drush -y site:install standard \
--root=/var/www/localhost/web \
--account-name=admin \
--account-pass=password \
--db-url=mysql://drupal:drupal@mysql/drupal
#--db-url=pgsql://drupal:drupal@pgsql/drupal
Login with admin / password:
docker exec -it -u apache dcd-php \
composer --working-dir=/var/www/localhost require \
drupal/admin_toolbar drupal/ctools drupal/pathauto drupal/token drupal/panels
With Linux, you can use included helper script
scripts/composer require drupal/admin_toolbar drupal/ctools drupal/pathauto drupal/token drupal/panels
docker exec -it -u apache dcd-php \
/var/www/localhost/vendor/bin/drush -y en \
--root=/var/www/localhost/web \
admin_toolbar ctools ctools_block ctools_views panels token pathauto
With Linux, you can use included helper script
scripts/drush -y en admin_toolbar ctools ctools_block ctools_views panels token pathauto
docker exec -it -u apache dcd-php \
ls -lah /var/www/localhost/web
docker exec -it -w /var/www/localhost -u apache dcd-php bash
Note: ./drupal/
is persistent but NOT the database files!
Save your database under Linux
scripts/mysql dump
scripts/pgsql dump
Stop and remove containers
docker-compose down
rm -rf data
For Ubuntu (16+) or Linux you can find in ./scripts/
multiple helpers to quickly
run some daily commands from root folder, and drush/drupal links at the root.
# Run drush or drupal within the container
scripts/drush status
scripts/drupal site:status
# Quickly dump/restore/drop your DB
scripts/mysql --help
scripts/pgsql --help
# Run composer as a service without local installation
scripts/composer --help
scripts/composer status
Install Drupal 8 variant helpers (This delete and replace existing Drupal in ./drupal
folder)
scripts/install-drupal.sh
scripts/install-drupal.sh list
scripts/install-drupal.sh install -p drupal-demo
Because this project is mainly focused on a one time usage, there is currently no upgrade path and the best way to upgrade is to dump and copy your project to a new version of this project.
You can find a script for Linux in scripts/get-tools.sh
folder to download or update all tools
chmod +x scripts/get-tools.sh
./scripts/get-tools.sh install
In case of any problem, first step is to check the configuration and the logs
docker-compose config
docker-compose logs
If you have already a web server running on port 80 or 443 on your machine you must stop it or change APACHE_HOST_HTTP_PORT in .env
Windows support very partial, before running docker-compose you must run in Powershell
$Env:COMPOSE_CONVERT_WINDOWS_PATHS=1
Some permissions and privileged problems
Want some help implementing this on your project? I provide Drupal 8 expertise as a freelance, just contact me.