Skip to content

tbsiqueira/docker-4-drupal-custom

Repository files navigation

docker-4-drupal-custom

This is a custom "ready-to-use" docker stack based on docker4Drupal. If you are looking for more information over the original docker4drupal, please refer to the section Docker-based Drupal stack

For a quick set-up guide please check the steps below.

Next improvements

  • Allow custom changes to the .env file;
  • Add behat tests;

Docker Desktop install

https://www.docker.com/products/docker-desktop

Assumptions

This docker-4-drupal-custom config assumes a couple of things:

  1. We removed the docker-compose.override.yml file because this should be a copy/paste docker stack;
  2. When using Xdebug, the IDE_KEY is fixed to phpstorm, feel free to change it;
  3. MacOS as machine OS;
  4. There are a lot of more options for this docker stack, but for the purpose of this custom set up we removed them;
  5. We are not using mutagen due to permission issues;
  6. The following tools are enabled by default:
    1. phpMyAdmin;
    2. Mailhog;

Installation example

Run the following command to install Drupal Social, and replace SOCIAL-DIRECTORY with the directory of your choice.

composer create-project goalgorilla/social_template:dev-master SOCIAL-DIRECTORY --no-interaction

Copy the entire content of docker-4-drupal-custom folder to a DOCKER-DIRECTORY of your choice inside the newly cloned Drupal Social directory.

The folder structure should be like this:

[SOCIAL-DIRECTORY]
  - [CLONED DRUPAL SOCIAL FOLDERS AND FILES]
  - [DOCKER-DIRECTORY]
     - Makefile ( to execute the docker commands )
     - Other files from this current docker-4-drupal-custom repo
  - [HTML - DRUPAL ACTUAL FILES] 

Once you copy the docker-4-drupal-custom files to the DOCKER-DIRECTORY edit the .env file and change the following to your choice:

COMPOSE_PROJECT_NAME=[COMPOSE_PROJECT_NAME]
PROJECT_NAME=[PROJECT_NAME]
PROJECT_BASE_URL=[PROJECT_BASE_URL].docker.localhost
PROJECT_PORT=[PROJECT_PORT]

For each project, you can set a different value at .env this way you can spin up multiple projects at once.

Go to DOCKER-DIRECTORY and execute the following:

make up

After the containers start, it's time to switch to the docker php container shell and install Drupal Social

make shell
dsisocial

Once the installation finishes, the website is available through the same url that was configured at .env file:

# Website
http://[PROJECT_BASE_URL].docker.localhost:[PROJEC_PORT]

# phpMyAdmin
http://pma.[PROJECT_BASE_URL].docker.localhost:[PROJEC_PORT]

# Mailhog
http://mailhog.[PROJECT_BASE_URL].docker.localhost:[PROJEC_PORT]

Custom aliases for the php container

Command Description
dsi Drush install a new site with admin/admin credentials and download and enable admin_toolbar.
dsisocial Drush install open social profile ( requires the right codebase ).
stanbaseline Creates a new php stan baseline. Please note that the stan scripts needs to be adjusted to the root "/var/www/html/html".
stancheck Executes the phpstan check.
cscheck Executes the code sniffer checks.
unitcheck Executes the unit tests on social profile.
allcheck Executes all tests.
importdb {database-name} [true] Import a database from "[DOCKER-DIRECTORY]/_resources/database-dumps/{database-name}.sql", if second parameter is true db-update will be executed

Xdebug and PHP Storm

Xdebug should work out of the box from the server, there is only one configuration needed:

  1. Preference > Settings > PHP > Servers;
  2. Add a new server with name phpstorm;
  3. Host should be http://[PROJECT_BASE_URL].docker.localhost;
  4. Port [PROJECT_PORT];
  5. Check Use path mappings;
  6. The root folder of your SOCIAL-DIRECTORY should map to /var/www/html;
  7. Save > Good to go!

Custom directories

This configuration has two custom directories:

  • database-data
    • Storing of permanent database files;
  • database-init
    • Holds a [filename].sql.gz or a [filename].sql that will be imported once the docker spins up, only if there is not a mysql folder inside database-data;

Useful links

Makefile commands

Command Description
make up Start up containers.
make stop Stop containers.
make start Start containers without updating.
make prune Remove containers and their volumes.
make ps List running containers.
make shell Access php container via shell.
make composer Executes composer command in a specified COMPOSER_ROOT directory (default is /var/www/html)
make drush Executes drush command in a specified DRUPAL_ROOT directory (default is /var/www/html/html)
make logs [service-name] View containers logs or view specific service log.

Docker-based Drupal stack

Introduction

Docker4Drupal is a set of docker images optimized for Drupal. Use docker-compose.yml file from the latest stable release to spin up local environment on Linux, Mac OS X and Windows.

Stack

The Drupal stack consist of the following containers:

Container Versions Image ARM64 support Enabled by default
Nginx 1.21, 1.20, 1.19 wodby/nginx
Apache 2.4 wodby/apache
Drupal 9, 8, 7 wodby/drupal
PHP 8.0, 7.4, 7.3 wodby/drupal-php
Crond wodby/drupal-php
MariaDB 10.5, 10.4, 10.3, 10.2 wodby/mariadb
PostgreSQL 13, 12, 11, 10, 9.6 wodby/postgres
Redis 6, 5 wodby/redis
Memcached 1 wodby/memcached
Varnish 6.0, 4.1 wodby/varnish
Node.js 16, 14, 12 wodby/node
Drupal node 1.0 wodby/drupal-node
Solr 8, 7, 6, 5 wodby/solr
Elasticsearch 7, 6 wodby/elasticsearch
Kibana 7, 6 wodby/kibana
OpenSMTPD 6.0 wodby/opensmtpd
Mailhog latest mailhog/mailhog
AthenaPDF 2.16.0 arachnysdocker/athenapdf-service
Rsyslog latest wodby/rsyslog
Blackfire latest blackfire/blackfire
Webgrind 1 wodby/webgrind
Xhprof viewer latest wodby/xhprof
Adminer 4.6 wodby/adminer
phpMyAdmin latest phpmyadmin/phpmyadmin
Selenium chrome 3.141 selenium/standalone-chrome
Traefik latest _/traefik

Supported Drupal versions: 9 / 8 / 7

Documentation

Full documentation is available at https://wodby.com/docs/stacks/drupal/local.

Image's tags

Images tags format is [VERSION]-[STABILITY_TAG] where:

[VERSION] is the version of an application (without patch version) running in a container, e.g. wodby/nginx:1.15-x.x.x where Nginx version is 1.15 and x.x.x is a stability tag. For some images we include both major and minor version like PHP 7.2, for others we include only major like Redis 5.

[STABILITY_TAG] is the version of an image that corresponds to a git tag of the image repository, e.g. wodby/mariadb:10.2-3.3.8 has MariaDB 10.2 and stability tag 3.3.8. New stability tags include patch updates for applications and image's fixes/improvements (new env vars, orchestration actions fixes, etc). Stability tag changes described in the corresponding a git tag description. Stability tags follow semantic versioning.

We highly encourage to use images only with stability tags.

Maintenance

We regularly update images used in this stack and release them together, see releases page for full changelog and update instructions. Most of routine updates for images and this project performed by the bot via scripts located at wodby/images.

Beyond local environment

Docker4Drupal is a project designed to help you spin up local environment with docker-compose. If you want to deploy a consistent stack with orchestrations to your own server, check out Drupal stack on Wodby .

Other Docker4x projects

License

This project is licensed under the MIT open source license.

About

A ready-to-use docker4drupal stack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published