This is an example project demonstrating how to set up a Drupal CMS based environment on Lagoon.
When running on a Lagoon instance, the first time that the project starts up, it will attempt to install Drupal-CMS - see the .lagoon.yml
file for how this is achieved using a post rollout task.
The ./.lagoon/scripts/scaffold.sh
script plays a key role in setting up the project, ensuring necessary dependencies and configurations are applied when running locally versus within Lagoon. See the file and the Dockerfile to see how this is achieved.
To set up and run the project locally, execute the following commands:
docker compose build
docker compose up -d
docker compose exec cli bash -c 'wait-for mariadb:3306'
docker compose exec cli bash -c 'drush -y si && drush -y cr'
These commands will:
- Build the necessary Docker containers.
- Start the containers in detached mode.
- Wait for the MariaDB service to become available.
- Install Drupal and rebuild the cache using Drush.
The Project Browser can be used to install modules through the UI when running locally. To do so:
- Visit
/admin/modules/browse/drupalorg_jsonapi
. - Install a module using the UI.
- This will update the
composer.json
andcomposer.lock
files. - Commit these changes to the repository and push them up.
- The module will still need to be enabled on the live site, but the composer packages will have been updated correctly.
The scaffold.sh
script is responsible for initializing the Drupal project in both local and Lagoon environments. It primarily:
- Installs dependencies when running locally.
- Ensures required configurations and files are in place.
- Prevents reinstallation if scaffolding has already been completed.
- The script checks for the presence of
/app/scaffolding_done.flag
. If found, it skips execution. - When running locally, it installs dependencies using
composer install --no-dev
and copies necessary configuration assets. - When running inside Lagoon, it ensures required setup files exist but skips dependency installation.
- It is executed as part of the container's entrypoints, as defined in the Dockerfile.
To ensure a smooth setup in cloud environments, auto-installation of the Project Browser has been disabled when running in Lagoon. This prevents conflicts and ensures proper configuration management.