Skip to content

Instantly share code, notes, and snippets.

@vladdancer
Last active March 20, 2018 14:31
Show Gist options
  • Save vladdancer/ed657a6a6cb22c8e96f07a9b1d5c77e4 to your computer and use it in GitHub Desktop.
Save vladdancer/ed657a6a6cb22c8e96f07a9b1d5c77e4 to your computer and use it in GitHub Desktop.
docker-compose example for testing Drupal
version: "2"
services:
mariadb:
image: wodby/mariadb:10.2-3.0.2
# image: wodby/mariadb:10.1-3.0.2
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
# volumes:
# - ./mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here.
# - /path/to/mariadb/data/on/host:/var/lib/mysql # I want to manage volumes manually.
# postgres:
# image: wodby/postgres:10.1-1.2.0
# image: wodby/postgres:9.6-1.2.0
# environment:
# POSTGRES_PASSWORD: password
# POSTGRES_DB: drupal
# POSTGRES_USER: drupal
# volumes:
# - ./postgres-init:/docker-entrypoint-initdb.d # Place init file(s) here.
# - /path/to/postgres/data/on/host:/var/lib/postgresql/data # I want to manage volumes manually.
php:
# 1. Images with vanilla Drupal – wodby/drupal:[DRUPAL_VERSION]-[PHP_VERSION]-[STABILITY_TAG].
# image: wodby/drupal:8-7.1-3.3.2
# image: wodby/drupal:8-7.0-3.3.2
# image: wodby/drupal:7-7.1-3.3.2
# image: wodby/drupal:7-7.0-3.3.2
# image: wodby/drupal:7-5.6-3.3.2
# image: wodby/drupal:6-5.6-3.3.2
# image: wodby/drupal:6-5.3-3.3.2
# 2. Images without Drupal – wodby/drupal-php:[PHP_VERSION]-[STABILITY_TAG].
image: wodby/drupal-php:7.1-3.3.1
# image: wodby/drupal-php:7.0-3.3.1
# image: wodby/drupal-php:5.6-3.3.1
# image: wodby/drupal-php:5.3-3.3.1
# 3. Images without Drupal – wodby/drupal-php:[PHP_VERSION]-[STABILITY_TAG]. Version for development (--enable-debug)
# image: wodby/drupal-php:7.1-dev-3.3.1
# image: wodby/drupal-php:7.0-dev-3.3.1
# image: wodby/drupal-php:5.6-dev-3.3.1
# image: wodby/drupal-php:5.3-dev-3.3.1
environment:
PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
PHP_FPM_CLEAR_ENV: "no"
DB_HOST: mariadb
DB_USER: drupal
DB_PASSWORD: drupal
DB_NAME: drupal
DB_DRIVER: mysql
#PHP_XDEBUG: 1
#PHP_XDEBUG_DEFAULT_ENABLE: 1
#PHP_XDEBUG_REMOTE_CONNECT_BACK: 0
#PHP_XDEBUG_REMOTE_HOST: "10.254.254.254"
#PHP_XDEBUG_PROFILER_OUTPUT_DIR: /mnt/files/xdebug/profiler
#PHP_XDEBUG_TRACE_OUTPUT_DIR: /mnt/files/xdebug/traces
# PHP_BLACKFIRE: 1
volumes:
# - codebase:/var/www/html
## Options for macOS users (https://docker4drupal.readthedocs.io/en/latest/macos)
- ./:/var/www/html:cached # User-guided caching
# - docker-sync:/var/www/html # Docker-sync
## For Xdebug profiler files
# - files:/mnt/files:cached?
nginx:
# wodby/drupal-nginx:[DRUPAL_VERSION]-[NGINX_VERSION]-[STABILITY_TAG].
image: wodby/drupal-nginx:8-1.13-3.0.2
# image: wodby/drupal-nginx:7-1.13-3.0.2
# image: wodby/drupal-nginx:6-1.13-3.0.2
# image: wodby/drupal-nginx:8-1.12-3.0.2
# image: wodby/drupal-nginx:7-1.12-3.0.2
# image: wodby/drupal-nginx:6-1.12-3.0.2
depends_on:
- php
environment:
NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
NGINX_ERROR_LOG_LEVEL: debug
NGINX_BACKEND_HOST: php
NGINX_SERVER_ROOT: /var/www/html/docroot
SIMPLETEST_BASE_URL: http://nginx
# NGINX_SERVER_EXTRA_CONF_FILEPATH: /var/www/html/notifier.conf
# NGINX_DRUPAL_FILE_PROXY_URL: example.com
volumes:
# - codebase:/var/www/html
# Options for macOS users (https://docker4drupal.readthedocs.io/en/latest/macos)
- ./:/var/www/html:cached # User-guided caching
# - docker-sync:/var/www/html # Docker-sync
labels:
- 'traefik.backend=nginx'
- 'traefik.port=80'
- 'traefik.frontend.rule=Host:drupal.docker.localhost'
phantomjs:
image: wernight/phantomjs:2
volumes_from:
- php
links:
- nginx
entrypoint: phantomjs
command: "--ssl-protocol=any --ignore-ssl-errors=true /var/www/html/docroot/vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768"
# apache:
# image: wodby/php-apache:2.4-2.0.2
# depends_on:
# - php
# environment:
# APACHE_LOG_LEVEL: debug
# APACHE_BACKEND_HOST: php
# APACHE_SERVER_ROOT: /var/www/html/web
# volumes:
# - codebase:/var/www/html
## Options for macOS users (https://docker4drupal.readthedocs.io/en/latest/macos)
## - codebase:/var/www/html:cached # User-guided caching
## - docker-sync:/var/www/html # Docker-sync
# labels:
# - 'traefik.backend=apache'
# - 'traefik.port=80'
# - 'traefik.frontend.rule=Host:drupal.docker.localhost'
# varnish:
# image: wodby/drupal-varnish:4.1-2.2.1
# depends_on:
# - nginx
# environment:
# VARNISH_SECRET: secret
# VARNISH_BACKEND_HOST: nginx
# VARNISH_BACKEND_PORT: 80
# labels:
# - 'traefik.backend=varnish'
# - 'traefik.port=6081'
# - 'traefik.frontend.rule=Host:varnish.drupal.docker.localhost'
# redis:
# image: wodby/redis:4.0-2.1.4
## image: wodby/redis:3.2-2.1.4
adminer:
image: wodby/adminer:4.3-1.1.0
environment:
ADMINER_SALT: adminer-salt
labels:
- 'traefik.backend=adminer'
- 'traefik.port=9000'
- 'traefik.frontend.rule=Host:adminer.drupal.docker.localhost'
# pma:
# image: phpmyadmin/phpmyadmin
# environment:
# PMA_HOST: mariadb
# PMA_USER: drupal
# PMA_PASSWORD: drupal
# PHP_UPLOAD_MAX_FILESIZE: 1G
# PHP_MAX_INPUT_VARS: 1G
# labels:
# - 'traefik.backend=pma'
# - 'traefik.port=80'
# - 'traefik.frontend.rule=Host:pma.drupal.docker.localhost'
# solr:
## wodby/drupal-solr:[DRUPAL_VERSION]-[SOLR_VERSION]-[STABILITY_TAG].
# image: wodby/drupal-solr:8-6.6-2.3.0
## image: wodby/drupal-solr:8-6.5-2.3.0
## image: wodby/drupal-solr:8-6.4-2.3.0
## image: wodby/drupal-solr:8-6.3-2.3.0
## image: wodby/drupal-solr:8-5.5-2.3.0
## image: wodby/drupal-solr:8-7.0-2.3.0
## image: wodby/drupal-solr:8-7.1-2.3.0
## image: wodby/drupal-solr:7-5.4-2.3.0
# environment:
# SOLR_HEAP: 1024m
# labels:
# - 'traefik.backend=solr'
# - 'traefik.port=8983'
# - 'traefik.frontend.rule=Host:solr.drupal.docker.localhost'
mailhog:
image: mailhog/mailhog
labels:
- 'traefik.backend=mailhog'
- 'traefik.port=8025'
- 'traefik.frontend.rule=Host:mailhog.drupal.docker.localhost'
# nodejs:
# image: wodby/drupal-node:1.0-1.0.0
# environment:
# NODE_SERVICE_KEY: node-service-key
# labels:
# - 'traefik.backend=nodejs'
# - 'traefik.port=8080'
# - 'traefik.frontend.rule=Host:nodejs.drupal.docker.localhost'
# volumes:
# - ./path/to/your/single-page-app:/app
# command: sh -c 'npm install && npm run start'
# node:
# image: node:alpine
# working_dir: /app
# labels:
# - 'traefik.backend=node'
# - 'traefik.port=3000'
# - 'traefik.frontend.rule=Host:front.drupal.docker.localhost'
# expose:
# - "3000"
# volumes:
# - ./path/to/your/single-page-app:/app
# command: sh -c 'npm install && npm run start'
# memcached:
# image: wodby/memcached:1.4-2.0.0
# rsyslog:
# image: wodby/rsyslog
# athenapdf:
# image: arachnysdocker/athenapdf-service:2.10.0
# environment:
# WEAVER_AUTH_KEY: weaver-auth-key
# WEAVER_ATHENA_CMD: "athenapdf -S"
# WEAVER_MAX_WORKERS: 10
# WEAVER_MAX_CONVERSION_QUEUE: 50
# WEAVER_WORKER_TIMEOUT: 90
# WEAVER_CONVERSION_FALLBACK: false
# blackfire:
# image: blackfire/blackfire
# environment:
# BLACKFIRE_SERVER_ID: XXXXX
# BLACKFIRE_SERVER_TOKEN: YYYYY
# webgrind:
# image: wodby/webgrind:1.5-1.0.0
# environment:
# WEBGRIND_PROFILER_DIR: /mnt/files/xdebug/profiler
# labels:
# - 'traefik.backend=webgrind'
# - 'traefik.port=8080'
# - 'traefik.frontend.rule=Host:webgrind.drupal.docker.localhost'
# volumes:
# - files:/mnt/files
portainer:
image: portainer/portainer
command: --no-auth -H unix:///var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock
labels:
- 'traefik.backend=portainer'
- 'traefik.port=9000'
- 'traefik.frontend.rule=Host:portainer.drupal.docker.localhost'
traefik:
image: traefik
command: -c /dev/null --web --docker --logLevel=INFO
ports:
- '8000:80'
# - '8080:8080' # Dashboard
volumes:
- /var/run/docker.sock:/var/run/docker.sock
volumes:
codebase:
## Docker-sync for macOS users
# docker-sync:
# external: true
## For Xdebug profiler
# files:
<?xml version="1.0" encoding="UTF-8"?>
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit bootstrap="tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true">
<!-- TODO set printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" once
https://youtrack.jetbrains.com/issue/WI-24808 is resolved. Drupal provides a
result printer that links to the html output results for functional tests.
Unfortunately, this breaks the output of PHPStorm's PHPUnit runner. However, if
using the command line you can add
- -printer="\Drupal\Tests\Listeners\HtmlOutputPrinter" to use it (note there
should be no spaces between the hyphens).
-->
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<!-- Do not limit the amount of memory tests take to run. -->
<ini name="memory_limit" value="-1"/>
<!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
<env name="SIMPLETEST_BASE_URL" value="http://nginx"/>
<!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix -->
<env name="SIMPLETEST_DB" value="mysql://drupal:drupal@mariadb/drupal"/>
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
<!-- To disable deprecation testing uncomment the next line. -->
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak_vendors"/>
<!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' -->
<!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' -->
<!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' -->
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["firefox", null, "http://localhost:4444/wd/hub"]' -->
</php>
<testsuites>
<testsuite name="unit">
<file>./tests/TestSuites/UnitTestSuite.php</file>
</testsuite>
<testsuite name="kernel">
<file>./tests/TestSuites/KernelTestSuite.php</file>
</testsuite>
<testsuite name="functional">
<file>./tests/TestSuites/FunctionalTestSuite.php</file>
</testsuite>
<testsuite name="functional-javascript">
<file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
</testsuite>
</testsuites>
<listeners>
<listener class="\Drupal\Tests\Listeners\DrupalListener">
</listener>
<!-- The Symfony deprecation listener has to come after the Drupal listener -->
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
</listener>
</listeners>
<!-- Filter for coverage reports. -->
<filter>
<whitelist>
<directory>./includes</directory>
<directory>./lib</directory>
<directory>./modules</directory>
<directory>../modules</directory>
<directory>../sites</directory>
<!-- By definition test classes have no tests. -->
<exclude>
<directory suffix="Test.php">./</directory>
<directory suffix="TestBase.php">./</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
docker-compose exec php sh
php ./core/scripts/run-tests.sh --url http://nginx --verbose --color --browser --php "/usr/
local/bin/php" --class "Drupal\Tests\content_translation\Functional\ContentTranslationLanguageChangeTest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment