Created to be cloned within a subdirectory in your Drupal codebase. Will need to enter the cloned source directory in your Drupal branch's .gitignore.
This project requires phpcov which requires a newer version of phpunit than Drupal currently ships with.
composer remove "phpunit/phpunit"
composer require --dev "phpunit/phpunit":"^5.1" "phpunit/phpcov":"^3.1"
gem install docker-sync
brew install fswatch
- Update 'scr' variable in syncs section in docker-sync.yml file
- After cloning this repo, at the project's root, make a local copy of the .env file:
cp .env.default .env
- In the newly-created
.env
file, setDOCROOT
to the root folder where your Drupal site exists
- i.e. if your site is in
project/web
set the variable toweb
- In the same
.env
file, setTHEME
to the folders where the site theme exists.
- i.e., if your site theme exists at
project/web/themes/custom_theme
. set the variable tothemes/custom_theme
- For all other variables set ports to not conflict with existing used ports on your host machine
- Create a new settings.php file based off of default.settings.php, and set the file's permissions to 777.
- Add the following line at the bottom of settings.php:
$config_directories['sync'] = 'sites/default/config/base';
-
Access the Drupal install screen. When you get to the database information form, enter the following:
database => project_db username => root password => secret host => mariadb port => 3306 driver => mysql
- In the
.env
file, modifyHOST_IP
to match an external IP
- Leverage Peter's handy dandy script in order to find a likely IP:
HOST_IP=$(ifconfig | awk '$0 ~ /inet / && $0 !~ /127.0.0.1/ {print $2; exit;}');
- Open your
hosts
file
docker-compose build
docker-compose up -d
To stop containers
docker-compose down
To stop containers and delete container data (will not delete the project files but will delete db and other information)docker-compose down -v
Access site at http://localhost:NGINX_HOST_HTTP_PORT
Access jenkins at http://localhost:JENKINS_HOST_PORT
Access sonarqube at http://localhost:SONARQUBE_HOST_PORT
Access phpmyadmin at 127.0.0.1:PMA_PORT
docker-sync-stack start
Alternatively:
docker-sync start
- In a new shell run after you started docker-sync
docker-compose -f docker-compose.yml -f docker-compose-dev.yml up -d
- Get a recent .sql file of the full DB, and run the following from the directory where the .sql file exists.
docker exec -i d4dd_mariadb_1 mysql -uroot -psecret project_db < your.db.sql
- Access the shell of the
php-fpm
container.
docker exec -i -t INSTANCE_NAME /bin/sh
...where INSTANCE_NAME is replaced by the php-fpm instance name (ie, d4dd_php-fpm_1)
- Move to the desired instance's Drupal root directory.
Default: cd /var/www/drupal/web
- Run the desired drush command.
drush YOUR_COMMAND_HERE
- Run
docker exec -i -t INSTANCE_NAME /bin/sh
..where INSTANCE_NAME is replaced by the instance name (ie, d4dd_php-fpm_1)
I'm running these containers on a Linux box, and I've heard there's a major security flaw inherent to using Docker on Linux. How do I secure the IP Tables?
A handy guide can be found here.
- create
/lib/systemd/system/docker.service.d/noiptables.conf
and fill it with the following info:
[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon --iptables=false
- In /etc/ufw/user.before, add the following rules above *filter:
*nat
:docker_postrouting - [0:0]
-A POSTROUTING -j docker_postrouting
-A docker_postrouting -s 172.16.0.0/12 ! -o br+ -j MASQUERADE
COMMIT
- In the same file, add the following before "COMMIT" at the bottom.
### DOCKER STUFF ###
-A FORWARD -i br+ -j ACCEPT
# for xdebug #
-A ufw-before-input -p tcp --dport 9000 -s 172.18.0.0/12 -j ACCEPT
### DOCKER END ###
I tried to run docker-compose up -d
and I got a strange error: No available IPv4 addresses on this network's address pools
. What gives?
- It may be because you have a VPN connection open. Please disconnect from the VPN & rerun
docker-compose up -d
.