- Docker
- Docker-compose
- PostgreSQL
- Composer
- Drush
- Drupal 9
Here is an overview of the working environment folder
├───config * * * * * * Docker images configurations folder
│ ├───dev * * * * * * Folder for the development environment
│ │ ├───apache2
│ │ ├───php
│ │ └───env
│ └───prod * * * * * Folder for production environment
│ ├───apache2
│ ├───php
│ └───env
├───postgresql * * * * * PostgreSQL configuration folder
│ └───gln_pg_initdb
└───var * * * * * * Root folder of the Apache web server
└───html * * * * * Drupal Management Root Folder with Composer
├───config * * * * Drupal configurations folder
│ ├───dev
│ ├───preprod
│ ├───prod
│ ├───qa
│ └───sync
├───features * * * Behat Test Folder
├───translations * * Drupal translations folder
└───web * * * * * Drupal Site Root Folder
├───libraries
├───modules
│ └───custom
├───profiles
├───sites
│ └───default
│ └───files
└───themes
└───custom
The database must be placed in the postgresql/gln_pg_initdb folder, to be imported during the construction of the PostgreSQL container.
├───postgresql
│ └───gln_pg_initdb
Before starting the containers, at the root of the Docker project, please copy the .env.default file, renaming it .env, then replace the varibales as you wish.
To test the project, you can leave the default variables.
# For deploy
ENV_ID=develop
# Drupal
DRUPAL_HOST=learn.mm
DRUPAL_TAG=1.0.0
DRUPAL_VERSION=9.3.8
DRUPAL_PORT=8076
DRUPAL_SITE_EMAIL=yeah@hello.mm
DRUPAL_SITE_NAME=Learn Drupal 9
# Drupal BO (For information only, so as not to forget :)
DRUPAL_SITE_ADMINISTRATOR=admin
DRUPAL_SITE_ADMINISTRATOR_PASS=admin
...- At the root of the project, launch the docker compose.
docker compose up -d --build- The
docker pscommand to list containers.
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
763g543h90pe learn/app/d9.3.8:1.0.1 "/opt/drupal/entrypo…" 33 minutes ago Up 33 minutes 0.0.0.0:8076->80/tcp learnapp
098erty65mpp dpage/pgadmin4 "/entrypoint.sh" 33 minutes ago Up 33 minutes 443/tcp, 0.0.0.0:5051->80/tcp learnpgadmin
the6Ed4532oj postgres "docker-entrypoint.s…" 33 minutes ago Up 33 minutes 0.0.0.0:5944->5432/tcp learnpgWhen you have launched your containers, execute the container of the application in order to download the php dependencies of Drupal with composer.
docker exec -it learnapp bashThen in the container, at the root of the /opt/drupal folder, I run composer install.
composer installFor the production environment, the composer install is launched in the Dockerfile script
# Install composer stuff
RUN composer install --no-devFor the build of the image and the deployment of the container:
- I go to the root of the project and I run the following command.
docker build -f ./config/production/Dockerfile -t learn/app/d9.3.8:1.0.1 --no-cache .- We tell Docker which Dockerfile to use
-f ./config/production/Dockerfile
- Then the name and the tags of the image
-t learn/app/d9.3.8:1.0.1
- We ask docker not to use caches
--no-cache
- We indicate the root location of the files to add in the images.
.