Drupal 8 Configuration Management
By Makeaweli
- 2 minutes read - 384 wordsModules
List all modules using Drush
drush pm-list --type=Module --status=enabled --no-core --format=list
Configuration
Drupal Console
Setup site for Drupal console:
drupal init --site --no-interaction
 Generation path: /opt/drupal/web
 1 - /root/.console/config.yml
 2 - /opt/drupal/console/config.yml
Dockerfile
WORKDIR /opt
RUN composer create-project drupal/recommended-project:8.9.3 drupal
RUN composer require drush/drush
RUN echo '$settings["config_sync_directory"] = "../config/sync";' >> web/sites/default/default.settings.php
COPY config /opt/drupal/web/sites/config/sync
RUN php -d memory_limit=-1 `which drush` site:install minimal --existing-config
Prep configuration from production server without Drush
- Export configuration from web ui.
 - Extract and configuration tarball.
 - View modules used in the core.extensions.yml file.
 - Install modules on dev server.
 - Install mystery sophron module
 
- include it also in core.extensions.yml before imagemagick
 
- Strip all instances of Standard profile from core.extensions.xml and replace it with ‘Minimal’ sed -i ’s/standard/minimal/g' /opt/drupal/web/sites/config/sync/core.extension.yml
 
Install custom modules
- Add custom repository to composer:
 
composer config repositories.repo-name vcs https://github.com/lullabot/custom_layouts.git
- Install module using composer
 
php -d memory_limit=-1 /usr/local/bin/composer require lullabot/custom_layouts
Build docker images
Drupal
3:17 to build on the rpi.
docker build . -t registry.gitlab.com/noirlab/noirlab-template/drupal-intra-fresh:8.9.3-20201113-arm64    
docker push registry.gitlab.com/noirlab/noirlab-template/drupal-intra-fresh:8.9.3-20201113-arm64 
Post docker build
Install drupal
21:43 to install on the rpi
docker exec -it noirlab-intranet_drupal_1 php -d memory_limit=-1 /opt/drupal/vendor/bin/drush site:install minimal --existing-config --account-name=admin --account-pass=tyb89kp
Uninstall LDAP modules
:32 on the rpi
docker exec -it noirlab-intranet_drupal_1 drush pm-uninstall ldap_authentication \
ldap_authorization \
ldap_help \
ldap_query \
ldap_servers \
ldap_user
Dump database to be used by Docker volume
docker exec noirlab-intranet_mariadb_1 sh -c 'exec mysqldump noirlab-intranet-drupal-8 -uroot -pgemini' > docker/mariadb/noirlab-intranet-drupal-8.20201019.sql
Build mariadb image with dump
- Modify dockerfile to add db dump
 - Use buildx to create multi-arch image:
 
1:13 on the rpi to build
docker buildx build . --push --platform linux/arm64,linux/amd64 -t registry.gitlab.com/noirlab/noirlab-template/mariadb-intra-fresh:10.5.6-20201113
Reconfigure docker environment
- Update docker-compose images for mariadb and drupal.
 - Delete all data in project maraidb directory
 - Restart docker-compose
 
Install default content
4:34 on the rpi
docker exec -it noirlab-intranet_drupal_1 drush pm-enable noirlab_default_content
docker exec -it noirlab-intranet_drupal_1 drush cache-rebuild
Workflow
- Build custom Drupal docker image
 
- Copy latest configuration files.
 - Modify configuration files to be compatible with fresh install of Drupal.
 - Install modules that are used by production server.
 - Misc. commands to disable specific modules, etc. suitable for dev environment.
 
- 
Install Drupal with configuration
 - 
Dump DB
 - 
Create custom MariaDB image using DB dump.
 - 
Use docker-compose with custom Drupal and MariaDB images.
 - 
Publish images to registry:
 
docker push registry.gitlab.com/noirlab/noirlab-template/drupal-intra-fresh:8.9.3-{YEARMONTHDAY}-arm64
docker push registry.gitlab.com/noirlab/noirlab-template/mariadb-intra-fresh:10.5.6-{YEARMONTHDAY}-arm64
- Install noirlab_default_content module and dump the DB and commit the Drupal image
 
docker commit {container hash} registry.gitlab.com/noirlab/noirlab-template/drupal-intra-content:8.9.3-{YEARMONTHDAY}-arm64
docker push registry.gitlab.com/noirlab/noirlab-template/mariadb-intra-content:10.5.6-{YEARMONTHDAY}-arm64