Skip to content

Instantly share code, notes, and snippets.

@WengerK
Last active August 27, 2020 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WengerK/b59768964ebf0458b5376dfa81894f51 to your computer and use it in GitHub Desktop.
Save WengerK/b59768964ebf0458b5376dfa81894f51 to your computer and use it in GitHub Desktop.
Drupal 8 contributed modules using Docker
language: php
services:
- docker
env:
global:
# The module name to be mounted and tested in the Docker.
- MODULE_NAME="my_module"
jobs:
include:
- name: D8.8
env: BASE_IMAGE_TAG="8.8"
- name: D8.9
env: BASE_IMAGE_TAG="8.9"
- name: D9.0
env: BASE_IMAGE_TAG="9.0"
before_install:
- docker-compose build --pull --build-arg BASE_IMAGE_TAG=${BASE_IMAGE_TAG} drupal
- docker-compose up -d drupal
# wait on Docker to be ready, especially MariaDB that takes many seconds to be up.
- docker-compose exec drupal wait-for-it drupal:80 -t 60
- docker-compose exec drupal wait-for-it db:3306 -t 60
before_script:
- docker-compose exec -u www-data drupal drush site-install standard --db-url="mysql://drupal:drupal@db/drupal" --site-name=Example -y
script:
- docker-compose exec -u www-data drupal phpunit --no-coverage --group=${MODULE_NAME} --configuration=/var/www/html/phpunit.xml

Article Ressources - Drupal 8 contributed modules using Docker

This is the Gist repository for my article Drupal 8 contributed modules using Docker.

Be aware that this article has been wrote for the Blog of Antistatique — Web Agency in Lausanne, Switzerland. A place where I work as Full Stack Web Developer.

Feel free to read it the full article on Medium or check it out on Antistatique.

Content of this Gist :

  • Dockerfile : Base Dockerfile that allow Drupal Version override for easy switch between images
  • docker-compose.yml : Standard docker-compose that create a drupal container (apache, php) with a mounted module and the database container
  • .travis.yml : Travis Integration example
version: '3.6'
services:
drupal:
build: .
depends_on:
- db
ports:
- 8888:80
volumes:
# Mount the module in the proper contrib module dir.
- .:/var/www/html/modules/contrib/my_module
restart: always
db:
image: mariadb:10.3.7
environment:
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_DATABASE: drupal
MYSQL_ROOT_PASSWORD: root
restart: always
ARG BASE_IMAGE_TAG=8.9.0
FROM wengerk/drupal-for-contrib:${BASE_IMAGE_TAG}
$ docker-compose build --pull --build-arg BASE_IMAGE_TAG=9.0 drupal
$ docker-compose up -d drupal
# wait on Docker to be ready, especially MariaDB that takes many seconds to be up before install.
$ docker-compose exec -u www-data drupal drush site-install standard --db-url="mysql://drupal:drupal@db/drupal" --site-name=Example -y
$ docker-compose build --pull
$ docker-compose up -d drupal
# wait on Docker to be ready, especially MariaDB that takes many seconds to be up before install.
$ docker-compose exec -u www-data drupal drush site-install standard --db-url="mysql://drupal:drupal@db/drupal" --site-name=Example -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment