From 8557ca41760b931b0be336865f0d11177f49007b Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Fri, 23 Feb 2024 01:41:02 +1100 Subject: [PATCH 01/31] Add full lando - with ahoy and lando tooling --- .ahoy.yml | 152 ++++ .gitignore | 1 + .lando.base.yml | 669 ++++++++++++++++++ ....dist.example.with-ssh-external-volume.yml | 26 + .lando.local.example.yml | 100 +++ .lando/container/scripts/ahoy-run.sh | 8 + .lando/container/scripts/db-import-prompt.sh | 14 + .lando/networks.external.yml | 3 + scripts/scaffold-init.sh | 7 + 9 files changed, 980 insertions(+) create mode 100644 .lando.base.yml create mode 100644 .lando.dist.example.with-ssh-external-volume.yml create mode 100644 .lando.local.example.yml create mode 100755 .lando/container/scripts/ahoy-run.sh create mode 100755 .lando/container/scripts/db-import-prompt.sh create mode 100644 .lando/networks.external.yml diff --git a/.ahoy.yml b/.ahoy.yml index ca02919..c60566f 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -156,3 +156,155 @@ commands: init: usage: Initialise codebase with project name, type (saas|paas|saasplus) and version (8|9) cmd: scripts/scaffold-init.sh -n $1 -t $2 -v $3 + + ##################### + ## Lando commands ### + ##################### + lando: + service: cli + cmd: echo Use \`ahoy lando-[command]\` to run specific ahoy lando commands instead. + + lando-up: + usage: Build project. [Lando] + cmd: | + lando start "$@" && + ahoy lando-info; + + lando-down: + usage: Delete project (CAUTION). [Lando] + # `lando destroy` already has a prompt. + cmd: lando destroy + + lando-build: + usage: Build project. [Lando] + cmd: | + lando rebuild "$@" + ahoy lando-govcms-deploy && ahoy lando-info; + + lando-cli: + usage: Start a shell inside cli container. [Lando] + cmd: lando ssh -s cli + + lando-run: + usage: Run command inside cli container. [Lando] + cmd: docker exec -it $(ahoy lando-app-name)_cli_1 bash -c "$*" + + lando-govcms-deploy: + usage: Runs deployment commands (e.g. config import, updb, cr, set up file_stage_proxy). [lando] + cmd: | + lando ssh -s cli -c "mkdir -p /app/web/sites/default/files/private/tmp && \ + /app/vendor/bin/govcms-db-update && \ + /app/vendor/bin/govcms-config-import && \ + /app/vendor/bin/govcms-cache-rebuild && \ + /app/vendor/bin/govcms-enable_modules" + + lando-drush: + usage: Run drush commands in cli container. [Lando] + cmd: lando drush "$@" + + lando-logs: + usage: Show Docker logs. [Lando] + cmd: lando logs "$@" + + lando-ps: + usage: List running Docker containers. [Lando] + # Find Lando app name and pass to docker docker container ls + cmd: ahoy lando-app-name | { read result; head -1; docker container ls -a | grep $result; } + + lando-restart: + usage: Restart Docker containers. [Lando] + cmd: lando restart + + lando-stop: + usage: Stop Docker containers. [Lando] + cmd: lando stop "$@" + + lando-install: + usage: Install the profile. [Lando] + cmd: | + ahoy confirm "Running this command will destroy your current site, are you sure?" && \ + (lando ssh -u 0 -s cli -c "drush si -y govcms \"$@\"" && ahoy lando-govcms-deploy) || \ + echo "Cancelled." + + lando-login: + usage: Login to a website. [Lando] + cmd: | + lando ssh -s cli -c "drush -y cset tfa.settings reset_pass_skip_enabled true" && \ + lando ssh -s cli -c "drush uinf --uid 1 --field name" | xargs -I % lando ssh -s cli -c "drush uublk %" && \ + lando ssh -s cli -c "drush uli" + + lando-unloop: + usage: Fix local redirect loop [Lando] + # Make the PHP code, escape it and run in docker not lando due to issue + # lando/lando#212 + cmd: | + DRUSH_TEMP_COMMAND=$(cat <<'END' + $u=\Drupal\user\Entity\User::load(1); $u->set("field_password_expiration", "0"); $u->save(); + $u=\Drupal\user\Entity\User::load(1); $u->set("field_last_password_reset", date("Y-m-d\TH:i:s")); $u->save(); + END + ); DRUSH_TEMP_COMMAND="$(printf "\"%q\"" $DRUSH_TEMP_COMMAND)" + docker exec -it $(ahoy lando-app-name)_cli_1 bash -c "drush ev \"$DRUSH_TEMP_COMMAND\"" + + lando-mysql-import: + usage: Pipe in a sql file. `ahoy lando-mysql-import local.sql` [Lando] + cmd: | + if [ -e "$@" ] ; then + lando ssh -s cli -c 'drush sql-drop' && + lando ssh -s cli -c 'drush sql-cli' < "$@" + else echo "Provided sql file" "$@" "does not exist" + fi + + lando-mysql-dump: + usage: Dump data out into a file. `ahoy lando-mysql-dump local.sql` [Lando] + cmd: lando ssh -s cli -c 'drush sql-dump --ordered-dump' > "$@" + + lando-lint: + usage: Lint code [Lando] + cmd: | + lando ssh -s test -c ./vendor/bin/govcms-lint web/modules/custom + lando ssh -s test -c ./vendor/bin/govcms-lint web/themes/custom + + lando-test-behat: + usage: Run Behat tests. [Lando] + cmd: lando ssh -s test -c ./vendor/bin/govcms-behat "$@" + + lando-test-phpunit: + usage: Run phpunit tests [Lando] + cmd: lando ssh -s test -c ./vendor/bin/govcms-phpunit --testsuite govcms + + lando-refresh-db: + usage: Refresh the database container with latest nightly dump. [Lando] + cmd: | + ahoy confirm "Running this command will replace your current database. Are you sure?" && + ( cat .env | grep ^MARIADB_DATA_IMAGE | cut -c20- \ + | xargs -n1 docker pull; docker rm -f -v $(ahoy lando-app-name)_mariadb_1 \ + && lando start ) || + echo OK, probably a wise choice... + + lando-ship-shape: + usage: Run site validation scripts locally [Lando] + cmd: | + docker exec -it $(ahoy lando-app-name)_cli_1 bash -c "shipshape -f /app/vendor/govcms/scaffold-tooling/shipshape.yml --exclude-db --error-code \"$@\"" + + lando-debug: + usage: Enable debug configuration. [Lando] + cmd: | + { ahoy lando-run "php -v|grep -q Xdebug" && echo "Debug is already enabled. Use \`export XDEBUG_ENABLE="" && lando rebuild\` to disable."; } \ + || { export XDEBUG_ENABLE="true" && lando rebuild && \ + ahoy lando-run "php -v|grep -q Xdebug" && echo "Enabled debug configuration. Use \`export XDEBUG_ENABLE="" && lando rebuild\` to disable." || \ + echo "Enabling debug configuration failed."; } + + lando-info: + usage: Print information about this project. [Lando] + cmd: | + echo "Project : "$(ahoy lando-run "echo \$LAGOON_PROJECT" 2>/dev/null) + echo "Site local URL : "$(ahoy lando-run "echo \$LAGOON_ROUTE" 2>/dev/null) + echo "DB port on host : "$(docker port $(ahoy lando-app-name 2>/dev/null)_mariadb_1 3306 | cut -d : -f 2) + if [ "$1" ]; then + echo "One-time login : " $(ahoy lando-login -- --no-browser) + fi + + # Helpers. + lando-app-name: + cmd: lando info 2>/dev/null | grep hostnames | grep -o -P "[^\.]*.internal('|\")" | awk -F . '{print $1}' | head -n 1 + hide: true diff --git a/.gitignore b/.gitignore index d9722a0..425d826 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ console # Local development tools. docker-compose.override.yml +.lando.local.yml diff --git a/.lando.base.yml b/.lando.base.yml new file mode 100644 index 0000000..041b828 --- /dev/null +++ b/.lando.base.yml @@ -0,0 +1,669 @@ +################## +## Instructions ## +################## + +# This file is designed to be used with an alternative docker-compose wrappe +# tool 'lando'. Installation instructions for the tool can be found here: +# - Mac OS - https://docs.lando.dev/install/macos.html +# - Linux OS - https://docs.lando.dev/install/linux.html +# - Windows via WSL - https://docs.lando.dev/install/linux.html#caveats +# --- (for best performance, install the full docker desktop in windows with WSL +# intergration, then the install lando in the WSL via the `caveats` way. + +# 1. Initialise the project, if not already done +# (skip this step if this project has already been provided by govcms, ahoy +# command fails or file '[project]/scripts/scaffold-init.sh' does not exist.) + +# Command: +# `ahoy init [project_name] [type] [version]` +# OR +# `./scripts/scaffold-init.sh -n [project_name] -t [type] -v [version]` + +# Where: +# - '[project_name]': Is your project name +# - '[type]': May be 'saas' or 'paas' +# - '[version]': May be '8', '9' or '10' + +# 2. Enable local overrides by duplicating .lando.local.example.yml to +# .lando.local.yml + +# Command: `cp -i .lando.local.example.yml .lando.local.yml` + +# 3. Adjust '.lando.local.yml' if required. For example, toggle DEV_MODE, +# set MARIADB_DATA_IMAGE or make the lando project name/urls unique for multiple +# instances of this same project on the same computer. + +# 4. Optional, Enable SSH agent integration with pygmy. + +# See heading in this file 'SSH agent volume with pygmy' for steps. + +# 5. Run the project. + +# Command: `lando start` + +####################### +## IMPORTANT - Notes ## +####################### + +# If you get a error "ERROR ==> (HTTP code 500) server error - container +# is not connected to the network lando_bridge_network" +# Then just run "lando rebuild" again. + +############################################ +## SSH agent volume with pygmy - Optional ## +############################################ + +# Creating a new SSH agent container is optional for integration, if required +# with pymgy SSH agent. To use, rename +# '.lando.dist.example.with-ssh-external-volume.yml' to .lando.dist.yml', +# rebuild lando and fellow the terminal commands below. + +# Why? +# In Docker compose v3, the' volumes_from' property, which maps volumes from one +# container to another another, cannot be used. The new method, is to specify +# the volume by name, however, the amazee.io SSH agent creates randomly named +# volume, so rename it first. + +# +# OLD_VOLUME=$(docker inspect --type=container --format='{{ (index .Mounts 0).Name }}' amazeeio-ssh-agent) +# docker volume create amazeeio-ssh-agent-volume +# +# docker run --rm -it -v $OLD_VOLUME:/from -v amazeeio-ssh-agent-volume:/to alpine ash -c "cd /from ; cp -av . /to" +# docker run -d --name amazeeio-ssh-agent-new-container \ +# -v amazeeio-ssh-agent-volume:/tmp/amazeeio_ssh-agent \ +# --restart=unless-stopped \ +# pygmystack/ssh-agent +# +# docker container rm amazeeio-ssh-agent -f +# docker rename amazeeio-ssh-agent-new-container amazeeio-ssh-agent +# docker volume rm $OLD_VOLUME +# + +################ +## Misc notes ## +################ + +# The default order of .lando.yml file merge order is: +# preLandoFiles: +# - .lando.base.yml +# - .lando.dist.yml +# - .lando.upstream.yml +# landoFile: .lando.yml +# postLandoFiles: +# - .lando.local.yml + +################################# +## GovCMS Docker Configuration ## +################################# + +###################### +## !! IMPORTANT !!! ## +## To run multiple copies of the same project, the following properties must be +## unique per project: +## - lagoon-project `x-lagoon-project` +## - default-url (which affects LAGOON_ROUTE / LOCALDEV_URL) `x-default-url` +## - lando proxy urls `proxy` +###################### + +# This value intentionally matches the project name on Lagoon. +# It is used to name the CLI_IMAGE to use as a build arg locally. +x-lagoon-project: &lagoon-project {{ GOVCMS_PROJECT_NAME }} + +x-default-url: &default-url ${LOCALDEV_URL:-http://{{ GOVCMS_PROJECT_NAME }}.docker.amazee.io} + +# Lando proxy urls. +proxy: + nginx: + hostname: {{ GOVCMS_PROJECT_NAME }}-nginx.lndo.site:8080 + # solr: + # hostname: {{ GOVCMS_PROJECT_NAME }}-solr.lndo.site:8983 + +# See GOVCMS_IMAGE_VERSION in "Variables" at https://github.com/govCMS/govCMS/wiki +x-govcms-image-version: &govcms-image-version ${GOVCMS_IMAGE_VERSION:-10.x-latest} + +x-volumes: + volumes: + - &volume-drupal-themes ./themes:/app/web/themes/custom:${VOLUME_FLAGS:-delegated} + - &volume-drupal-files ./files:/app/web/sites/default/files:delegated + - &volume-behat-features ./tests/behat/features:/app/tests/behat/features:${VOLUME_FLAGS:-delegated} + - &volume-behat-screenshots ./tests/behat/screenshots:/app/tests/behat/screenshots:${VOLUME_FLAGS:-delegated} + - &volume-phpunit-tests ./tests/phpunit/tests:/app/tests/phpunit/tests:${VOLUME_FLAGS:-delegated} + - &volume-drupal-config ./config:/app/config + +x-volumes-paas: + volumes: + - &volume-drupal-app .:/app:delegated + +# The property, 'volumes_from' was removed in docker compose v3, so use named +# volumes instead. +# Mount volumes from Pygmy to inject host SSH key into container. +# https://pygmy.readthedocs.io/en/master/ssh_agent/ +x-volumes-external: + volumes: + - &volume-ssh-agent amazeeio-ssh-agent-volume:/tmp/amazeeio_ssh-agent + +x-volumes-tooling: + volumes: + - &volume-tooling ./.lando/container:/lando-govcms + +# YAML Merge key doesn't work with arrays so use anchors instead/ +x-volumes-with-external: &default-volumes-with-external + volumes: + - *volume-drupal-themes + - *volume-drupal-files + - *volume-behat-features + - *volume-behat-screenshots + - *volume-phpunit-tests + - *volume-drupal-config + - *volume-ssh-agent + - *volume-tooling + +x-volumes-paas-with-external: &paas-volumes-with-external + volumes: + - *volume-drupal-app + - *volume-ssh-agent + - *volume-tooling + +# Entry point process isn't PID 1 as lando entrypoint is instead, +# so force it to run. +x-extra-environment-tini: &extra-environment-tini + - TINI_SUBREAPER: true + +x-environment: &default-environment + STAGE_FILE_PROXY_URL: ${STAGE_FILE_PROXY_URL:-} + LAGOON_ENVIRONMENT_TYPE: ${LAGOON_ENVIRONMENT_TYPE:-} + LAGOON_PROJECT: *lagoon-project + LAGOON_ROUTE: *default-url + LOCALDEV_URL: *default-url + GOVCMS_IMAGE_VERSION: ${GOVCMS_IMAGE_VERSION:-10.x-latest} + DEV_MODE: "${DEV_MODE:-false}" + XDEBUG_ENABLE: ${XDEBUG_ENABLE:-} + DOCKERHOST: ${DOCKERHOST:-host.docker.internal} + X_FRAME_OPTIONS: ${X_FRAME_OPTIONS:-SameOrigin} + DRUPAL_SHIELD_USER: ${DRUPAL_SHIELD_USER:-} + DRUPAL_SHIELD_PASS: ${DRUPAL_SHIELD_PASS:-} + GOVCMS_DEPLOY_WORKFLOW_CONFIG: ${GOVCMS_DEPLOY_WORKFLOW_CONFIG:-import} + GOVCMS_PREPARE_XML_SCRIPT: /app/vendor/bin/govcms-prepare-xml + CLAMAV_HOST: av + CLAMAV_MODE: daemon + << : *extra-environment-tini + +######################### +## Lando configuration ## +######################### + +# Unique lando project name. +name: *lagoon-project + +# Note: Vars only work in the containers, not in the lando.yml files and only if +# NOT defined in the .lando.yml files, otherwise lando yml takes precedence, +# unlike docker-compose.yml. +# @see https://github.com/lando/lando/issues/1616 +env_file: + - .env + +# Define internal/external network 'amazeeio-network'. +compose: + - .lando/networks.external.yml + +x-lando-common-options: &lando-common-options + api: 3 + type: lando + # Do not auto mount /app folder by default. + app_mount: false + +# Mark volume as internal for each service, use override for external. +x-lando-volumes-top-level: &lando-volumes-top-level + volumes: + amazeeio-ssh-agent-volume: + external: false + +x-lando-database-tooling-vars: &lando-database-tooling-vars + MYSQL_DATABASE: drupal + LANDO_DB_EXPORT_USER: drupal + LANDO_DB_IMPORT_USER: drupal + # A default password is set, so override it, we can't force a blank password + # without creating defaults file and that defaults parameter must be first, + # but the default lando script places the extra paramters at the end, so use + # the druapl user. + LANDO_EXTRA_DB_EXPORT_ARGS: -pdrupal --single-transaction + LANDO_EXTRA_DB_IMPORT_ARGS: -pdrupal + +x-lando-tooling-mysql-cmd: &lando-mysql-cli-cmd 'mysql -udrupal -pdrupal -h 127.0.0.1 drupal' + +x-lando-tooling-ahoy-info-cmd: &lando-tooling-ahoy-info-cmd | + echo -e "\e[96m#### Project : $LAGOON_PROJECT \e[0m" + echo -e "\e[96m#### Site local URL : $LAGOON_ROUTE \e[0m" + echo -e "\e[96m#### DB port on host : [run \`docker port ${LANDO_APP_PROJECT}_mariadb_1 3306 | cut -d : -f 2\`]" + +x-lando-tooling-ahoy-govcms-deploy-cmd: &lando-tooling-ahoy-govcms-deploy-cmd | + mkdir -p /app/web/sites/default/files/private/tmp && \ + /app/vendor/bin/govcms-db-update && \ + /app/vendor/bin/govcms-config-import && \ + /app/vendor/bin/govcms-cache-rebuild && \ + /app/vendor/bin/govcms-enable_modules + +x-lando-extra-build-steps: &lando-extra-build-steps + build_as_root: + # Add pv. + - | + if apk list | grep "{pv}" > /dev/null | grep -q pv; then + # Run this if confirm returns true. + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) PV is already installed. ####\e[0m"; + else + # Run this if confirm returns false. + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) Installing PV. ####\e[0m" && + apk add pv && + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) PV install done. ####\e[0m"; + fi + +############## +## Services ## +############## + +services: + cli: + << : *lando-common-options + << : *lando-extra-build-steps + << : *lando-volumes-top-level + services: + build: + context: . + dockerfile: .docker/Dockerfile.cli + args: + LAGOON_SAFE_PROJECT: *lagoon-project + GOVCMS_IMAGE_VERSION: *govcms-image-version + GOVCMS_GITHUB_TOKEN: ${GOVCMS_GITHUB_TOKEN:-} + image: *lagoon-project + labels: + lagoon.type: cli-persistent + lagoon.persistent.name: nginx + lagoon.persistent: /app/web/sites/default/files/ + environment: + << : *default-environment + networks: + - amazeeio-network + - default + # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. + command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep + << : *default-volumes-with-external + + test: + << : *lando-common-options + << : *lando-volumes-top-level + services: + build: + context: . + dockerfile: .docker/Dockerfile.test + args: + CLI_IMAGE: *lagoon-project + GOVCMS_IMAGE_VERSION: *govcms-image-version + SITE_AUDIT_VERSION: ${SITE_AUDIT_VERSION:-7.x-3.x} + labels: + lagoon.type: none + depends_on: + - cli + environment: + << : *default-environment + networks: + - amazeeio-network + - default + # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. + command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep + << : *default-volumes-with-external + + nginx: + << : *lando-common-options + << : *lando-volumes-top-level + # Expose Nginx via lando proxy, note that 'ports' must also be present in + # 'services'. + moreHttpPorts: + - '8080' + # Skip Lando checking for service to be healthy, the site might not be + # installed yet and Lando DNS might not be setup either. + scanner: false + services: + build: + context: . + dockerfile: .docker/Dockerfile.nginx-drupal + args: + CLI_IMAGE: *lagoon-project + GOVCMS_IMAGE_VERSION: *govcms-image-version + labels: + lagoon.type: nginx-php-persistent + lagoon.persistent: /app/web/sites/default/files/ + depends_on: + - cli + environment: + << : *default-environment + LAGOON_LOCALDEV_URL: *default-url + networks: + - amazeeio-network + - default + # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. + command: /sbin/tini -- /lagoon/entrypoints.sh nginx -g 'daemon off;' + # Required for lando proxy 'moreHttpPorts'. + ports: + - '8080' + << : *default-volumes-with-external + + php: + << : *lando-common-options + << : *lando-volumes-top-level + services: + build: + context: . + dockerfile: .docker/Dockerfile.php + args: + CLI_IMAGE: *lagoon-project + GOVCMS_IMAGE_VERSION: *govcms-image-version + labels: + lagoon.type: nginx-php-persistent + lagoon.name: nginx + lagoon.persistent: /app/web/sites/default/files/ + depends_on: + - cli + environment: + << : *default-environment + networks: + - amazeeio-network + - default + command: /sbin/tini -- /lagoon/entrypoints.sh /usr/local/sbin/php-fpm -F -R + << : *default-volumes-with-external + + mariadb: + << : *lando-common-options + << : *lando-extra-build-steps + # Mount the app folder, for db import, db-export. + app_mount: true + services: + image: ${MARIADB_DATA_IMAGE:-govcms/mariadb-drupal:10.x-latest} + labels: + lagoon.type: mariadb + lagoon.image: govcms/mariadb-drupal:10.x-latest + ports: + - '3306' # Find port on host with `docker port [container_name_for_mariadb] 3306` + environment: + << : *default-environment + command: /sbin/tini -- /lagoon/entrypoints.bash mysqld + # Keep index data across lando rebuilds. (1 of 2) + volumes: + # Keep database across lando rebuilds by using named volumes. (1 of 2) + - data_mariadb_blank:/var/lib/mysql + - data_mariadb_govcms_image:/var/lib/db-data + - *volume-tooling + # Keep database across lando rebuilds by using named volumes. (2 of 2) + volumes: + data_mariadb_blank: + data_mariadb_govcms_image: + healthcheck: + command: mysql -uroot --silent --execute "SHOW DATABASES;" + av: + << : *lando-common-options + services: + image: govcms/av:latest + labels: + lagoon.type: none + environment: + << : *extra-environment-tini + command: /init /bin/sh -c "freshclam --checks=1 --daemon --foreground --stdout --user=clamav && rm /var/lib/clamav/freshclam.dat || rm /var/lib/clamav/mirrors.dat || true" + + # Uncomment to enable solr and `proxy` => `solr`. + # solr: + # << : *lando-common-options + # # Expose SOLR via lando proxy. + # moreHttpPorts: + # - '8983' + # # Skip Lando checking for service to be healthy, the site might not be + # # installed yet and Lando DNS might be setup either. + # scanner: false + # services: + # build: + # context: . + # dockerfile: .docker/Dockerfile.solr + # args: + # GOVCMS_IMAGE_VERSION: *govcms-image-version + # labels: + # lagoon.type: solr + # ports: + # - '8983' # Find port on host with `docker port [container_name_for_solr] 8983` + # depends_on: + # - cli + # environment: + # << : *default-environment + # command: /sbin/tini -- /lagoon/entrypoints.sh solr-foreground + + chrome: + << : *lando-common-options + << : *lando-volumes-top-level + services: + image: selenium/standalone-chrome:4.5.2-20221021 + shm_size: '1gb' + depends_on: + - test + labels: + lagoon.type: none + command: /opt/bin/entry_point.sh + << : *default-volumes-with-external + +########################### +## Drush / ahoy commands ## +########################### + +tooling: + ###### + ## Standard Lando Drupaly commands + ###### + composer: + service: cli + cmd: 'composer --ansi' + user: root + 'db-import ': + service: ':host' + description: 'Imports a dump file into a database service' + cmd: '/lando-govcms/scripts/db-import-prompt.sh /helpers/sql-import.sh' + user: 'root' + env: + << : *lando-database-tooling-vars + options: + 'host': + description: 'The database service to use' + default: 'mariadb' + alias: ['h'] + 'no-wipe': + description: 'Do not destroy the existing database before an import' + boolean: true + 'db-export [file]': + service: ':host' + description: 'Exports database from a database service to a file' + cmd: '/helpers/sql-export.sh' + user: 'root' + env: + << : *lando-database-tooling-vars + options: + host: + description: 'The database service to use' + default: 'mariadb' + alias: ['h'] + stdout: + description: 'Dump database to stdout' + php: + service: 'cli' + cmd: 'php' + mysql: + service: ':host' + description: 'Drops into a MySQL shell on a database service' + cmd: *lando-mysql-cli-cmd + options: + host: + description: 'The database service to use' + default: 'mariadb' + alias: ['h'] + drush: + service: cli + description: Run drush commands + cmd: drush + ############# + ## Ahoy equivalent commands. + ############# + ## Note: these run inside the container, not on the host, so `docker`/`lando` + ## commands cannot be used. + ahoy: + service: cli + description: Shows how to run the correct lando ahoy command. + cmd: echo Command not supported, Use \`lando ahoy-[command]\` to run ahoy commands instead. + ahoy-up: + service: cli + description: Build project. (use alternative command) + cmd: echo Command not supported, the lando command to run instead is \`lando start\`. + ahoy-down: + service: cli + description: Delete project (CAUTION). (use alternative command) + cmd: echo Command not supported, the lando command to run instead is \`lando destroy\`. + ahoy-build: + service: cli + description: Build project. (use alternative command) + cmd: | + echo Command not supported, the lando commands to run instead are: + echo " - \`lando rebuild\`" + echo " - \`lando ahoy-govcms-deploy\`" + echo " - \`lando ahoy-info\`" + echo Note: this will update the containers. + ahoy-cli: + service: cli + description: Start a shell inside cli container. + cmd: bash + ahoy-run: + service: cli + description: Run command inside cli container. + cmd: /lando-govcms/scripts/ahoy-run.sh + ahoy-govcms-deploy: + service: cli + description: Runs deployment commands (e.g. config import, updb, cr, set up file_stage_proxy). + cmd: *lando-tooling-ahoy-govcms-deploy-cmd + ahoy-drush: + service: cli + description: Run drush commands in cli container. + cmd: drush + ahoy-logs: + service: cli + description: Show Docker logs. (use alternative command) + cmd: | + echo Command not supported, the lando command to run instead is \`lando logs\`. + echo Useful parameters: + echo " --follow" + echo " --service=[service_name, e.g. php, cli, nginx etc.]" + echo "" + echo Logs can also be viewed by running \`docker logs ${LANDO_APP_PROJECT}_[service_name]_1\` + echo Useful parameters: + echo " --follow" + echo " --tail=[number]" + echo " (shows last X number of lines)" + ahoy-ps: + service: cli + description: List running Docker containers. (use alternative command) + cmd: | + echo Command not supported, the lando command to run instead is \`lando list --app ${LANDO_APP_PROJECT} --format=table\`. + echo Useful parameters: + echo " --format=[json,table]" + ahoy-restart: + service: cli + description: Restart Docker containers. (use alternative command) + cmd: echo Command not supported, the lando command to run instead is \`lando restart\`. + ahoy-stop: + service: cli + description: Stop Docker containers. (use alternative command) + cmd: echo Command not supported, the lando command to run instead is \`lando stop\`. + ahoy-install: + service: cli + description: Install the profile. + cmd: + - | + read -r -p "Running this command will destroy your current site, are you sure? [y/N] " response; + if [ "${response}" = "y" ]; then + # Run this if confirm returns true. + drush si -y govcms + else + # Run this if confirm returns false. + echo "Cancelled."; \ + exit 1; + fi + - *lando-tooling-ahoy-govcms-deploy-cmd + ahoy-login: + service: cli + description: Login to a website. + cmd: | + drush -y cset tfa.settings reset_pass_skip_enabled true && \ + drush uinf --uid 1 --field name | xargs drush uublk && \ + drush uli + ahoy-unloop: + service: cli + description: Fix local redirect loop + cmd: | + drush ev '$u=\Drupal\user\Entity\User::load(1); $u->set("field_password_expiration", "0"); $u->save()' && \ + drush ev '$u=\Drupal\user\Entity\User::load(1); $u->set("field_last_password_reset", date("Y-m-d\TH:i:s")); $u->save()' + ahoy-mysql-import: + service: cli + description: Pipe in a sql file. `lando ahoy-mysql-import mysql-import local.sql` (use alternative command) + cmd: echo Command not supported, instead run \`lando drush sql-drop && lando drush sql-cli < local.sql\`. + ahoy-mysql-dump: + service: cli + description: Dump data out into a file. `ahoy mysql-dump local.sql` (use alternative command) + cmd: echo Command not supported, instead run \`lando drush sql-dump --ordered-dump > local.sql\`. + ahoy-lint: + service: test + description: Lint code + cmd: | + ./vendor/bin/govcms-lint web/modules/custom + ./vendor/bin/govcms-lint web/themes/custom + ahoy-test-behat: + service: test + description: Run Behat tests + cmd: ./vendor/bin/govcms-behat + ahoy-phpunit: + service: test + description: Run phpunit tests + cmd: ./vendor/bin/govcms-phpunit --testsuite govcms + ahoy-pull: + service: cli + description: Pull latest docker images. (use alternative command) + cmd: | + echo Command not supported, instead run: + echo '`docker image ls --format \"{{.Repository}}:{{.Tag}}\" | grep govcms/ | grep -v none | xargs -n1 docker pull | cat`' + echo Note that \`lando rebuild\` updates images and rebuilds the containers. + ahoy-refresh-db: + service: cli + description: Refresh the database container with latest nightly dump. (use alternative command) + cmd: | + echo Command not supported, instead run: + echo '`read -r -p "Running this command will replace your current database. Are you sure? (yes/no) [no]:" response; \ + ([ ! "${response}" = "y" ] && [ ! "${response}" = "yes" ]) \ + && echo OK, probably a wise choice... \ + || (cat .env | grep ^MARIADB_DATA_IMAGE | cut -c20- \ + '"| xargs -n1 docker pull; docker rm -f -v ${LANDO_APP_PROJECT}_mariadb_1 \ + && lando start)\`" + ahoy-ship-shape: + service: cli + description: Run site validation scripts locally + cmd: shipshape -f /app/vendor/govcms/scaffold-tooling/shipshape.yml --exclude-db --error-code + ahoy-debug: + service: cli + description: Enable debug configuration (use alternative command) + cmd: | + echo Command not supported, instead run: + echo '`{ lando ahoy-run "php -v|grep -q Xdebug" && echo "Debug is already enabled. \ + Use \`export XDEBUG_ENABLE="" && lando rebuild\` to disable."; } \ + || { export XDEBUG_ENABLE="true" && lando rebuild && \ + lando ahoy-run "php -v|grep -q Xdebug" && echo "Enabled debug configuration. \ + && Use \`export XDEBUG_ENABLE="" && lando rebuild\` to disable."; }`' + ahoy-info: + service: cli + description: Print information about this project. + cmd: *lando-tooling-ahoy-info-cmd + +################## +## Lando Events ## +################## +events: + post-start: + - *lando-tooling-ahoy-info-cmd diff --git a/.lando.dist.example.with-ssh-external-volume.yml b/.lando.dist.example.with-ssh-external-volume.yml new file mode 100644 index 0000000..b9ada32 --- /dev/null +++ b/.lando.dist.example.with-ssh-external-volume.yml @@ -0,0 +1,26 @@ +######################### +## Lando configuration ## +######################### + +# Mark volume back to external, users need to create external volume though, +# See notes in main lando file. +x-lando-volumes-top-level: &lando-volumes-top-level + volumes: + amazeeio-ssh-agent-volume: + external: true + +############## +## Services ## +############## + +services: + cli: + << : *lando-volumes-top-level + test: + << : *lando-volumes-top-level + nginx: + << : *lando-volumes-top-level + php: + << : *lando-volumes-top-level + chrome: + << : *lando-volumes-top-level diff --git a/.lando.local.example.yml b/.lando.local.example.yml new file mode 100644 index 0000000..8fe5400 --- /dev/null +++ b/.lando.local.example.yml @@ -0,0 +1,100 @@ +############################### +## Local override for lando ## +############################## + +###################### +## !! IMPORTANT !!! ## +## To run multiple copies of the same project, the following properties must be +## unique per project: +## - lagoon-project `x-lagoon-project` +## - default-url (which affects LAGOON_ROUTE / LOCALDEV_URL) `x-default-url` +## - lando proxy urls `proxy` +###################### + +x-lagoon-project: &lagoon-project {{ GOVCMS_PROJECT_NAME }} + +x-default-url: &default-url http://{{ GOVCMS_PROJECT_NAME }}.docker.amazee.io + +# Lando proxy urls. +proxy: + nginx: + hostname: {{ GOVCMS_PROJECT_NAME }}-nginx.lndo.site:8080 + # solr: + # hostname: {{ GOVCMS_PROJECT_NAME }}-solr.lndo.site:8983 + +# lando doesn't define .env as dockers vars @see lando/lando#1616 +x-environment: &default-environment + COMPOSE_PROJECT_NAME: *lagoon-project + DEV_MODE: true + GOVCMS_IMAGE_VERSION: &govcms-image-version 10.x-latest + LAGOON_ENVIRONMENT_TYPE: local + LOCALDEV_URL: *default-url + MARIADB_DATA_IMAGE: &MARIADB_DATA_IMAGE govcms/mariadb-drupal:10.x-latest + #MARIADB_DATA_IMAGE: &MARIADB_DATA_IMAGE gitlab-registry-production.govcms.amazee.io/org/project/mariadb-drupal-data + #STAGE_FILE_PROXY_URL: http://govcms.docker.amazee.io + X_FRAME_OPTIONS: SameOrigin + #VOLUME_FLAGS: cached + GOVCMS_DEPLOY_WORKFLOW_CONFIG: import + LAGOON_PROJECT: *lagoon-project + LAGOON_ROUTE: *default-url + # XDEBUG_ENABLE: '' + # DOCKERHOST: host.docker.internal + # DRUPAL_SHIELD_USER: '' + # DRUPAL_SHIELD_PASS: '' + +x-others: + - SITE_AUDIT_VERSION: &SITE_AUDIT_VERSION 7.x-3.x + - GOVCMS_GITHUB_TOKEN: &GOVCMS_GITHUB_TOKEN '' + +############## +## Services ## +############## + +services: + cli: + services: + build: + args: + LAGOON_SAFE_PROJECT: *lagoon-project + GOVCMS_IMAGE_VERSION: *govcms-image-version + GOVCMS_GITHUB_TOKEN: *GOVCMS_GITHUB_TOKEN + image: *lagoon-project + environment: + << : *default-environment + + test: + services: + build: + args: + CLI_IMAGE: *lagoon-project + GOVCMS_IMAGE_VERSION: *govcms-image-version + SITE_AUDIT_VERSION: *SITE_AUDIT_VERSION + nginx: + services: + build: + args: + CLI_IMAGE: *lagoon-project + GOVCMS_IMAGE_VERSION: *govcms-image-version + environment: + << : *default-environment + LAGOON_LOCALDEV_URL: *default-url + php: + services: + build: + args: + CLI_IMAGE: *lagoon-project + GOVCMS_IMAGE_VERSION: *govcms-image-version + environment: + << : *default-environment + mariadb: + services: + image: *MARIADB_DATA_IMAGE + environment: + << : *default-environment + solr: + services: + build: + args: + GOVCMS_IMAGE_VERSION: *govcms-image-version + environment: + << : *default-environment diff --git a/.lando/container/scripts/ahoy-run.sh b/.lando/container/scripts/ahoy-run.sh new file mode 100755 index 0000000..483b193 --- /dev/null +++ b/.lando/container/scripts/ahoy-run.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +# Get the lando logger +. /helpers/log.sh + +# Run the command. +bash -c "$*" diff --git a/.lando/container/scripts/db-import-prompt.sh b/.lando/container/scripts/db-import-prompt.sh new file mode 100755 index 0000000..710666c --- /dev/null +++ b/.lando/container/scripts/db-import-prompt.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +# Get the lando logger +. /helpers/log.sh + +echo "Do you really want to import the database file? (yes/no) [no]:" +read -r -p " > " response; +if [ ! "${response}" = "y" ] && [ ! "${response}" = "yes" ]; then + # Abort. + lando_red "Cancelled." +else + bash -c "$*" +fi diff --git a/.lando/networks.external.yml b/.lando/networks.external.yml new file mode 100644 index 0000000..9504990 --- /dev/null +++ b/.lando/networks.external.yml @@ -0,0 +1,3 @@ +networks: + amazeeio-network: + external: true diff --git a/scripts/scaffold-init.sh b/scripts/scaffold-init.sh index c729f1d..c75d5d4 100755 --- a/scripts/scaffold-init.sh +++ b/scripts/scaffold-init.sh @@ -56,10 +56,16 @@ echo "[info]: Preparing scaffold for GovCMS$GOVCMS_VERSION ($GOVCMS_TYPE): $GOVC cp .env.default .env sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" .env && rm .env.bak sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" docker-compose.yml && rm docker-compose.yml.bak +sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" .lando.base.yml && rm .lando.base.yml.bak +sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" .lando.local.example.yml && rm .lando.local.example.yml.bak sed -i.bak "s/{{ GOVCMS_TYPE }}/$GOVCMS_TYPE/" .version.yml && rm .version.yml.bak sed -i.bak "s/{{ GOVCMS_TYPE }}/$GOVCMS_TYPE/" docker-compose.yml && rm docker-compose.yml.bak +sed -i.bak "s/{{ GOVCMS_TYPE }}/$GOVCMS_TYPE/" .lando.base.yml && rm .lando.base.yml.bak +sed -i.bak "s/{{ GOVCMS_TYPE }}/$GOVCMS_TYPE/" .lando.local.example.yml && rm .lando.local.example.yml.bak sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .version.yml && rm .version.yml.bak sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" docker-compose.yml && rm docker-compose.yml.bak +sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .lando.base.yml && rm .lando.base.yml.bak +sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .lando.local.example.yml && rm .lando.local.example.yml.bak sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .env && rm .env.bak sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .docker/Dockerfile* && rm .docker/Dockerfile*.bak @@ -80,6 +86,7 @@ else # Replace default/saas mounts for PaaS projects. sed -i.bak "s/*default-volumes/*paas-volumes/" docker-compose.yml && rm docker-compose.yml.bak + sed -i.bak "s/*default-volumes/*paas-volumes/" .lando.base.yml && rm .lando.base.yml.bak # Copy correct composer.json version into place. cp "composer.$GOVCMS_VERSION.json" composer.json From 534efbc0e94dea70afe36e6e8f3c78100637c50a Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 6 Mar 2024 14:57:38 +1100 Subject: [PATCH 02/31] Add lando `name` property lando local file so lando project name is unique and add note on changing MARIADB_DATA_IMAGE. --- .lando.base.yml | 14 +++++++++++++- .lando.local.example.yml | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.lando.base.yml b/.lando.base.yml index 041b828..4c70060 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -49,6 +49,18 @@ # is not connected to the network lando_bridge_network" # Then just run "lando rebuild" again. +# If swapping image via `MARIADB_DATA_IMAGE` AFTER using the lando project, then +# the database volumes must be removed first, otherwise it will use the old +# database. So use `lando destroy` or remove the database container and volumes +# via the below commands: +# +# LANDO_APP_NAME=$(lando info 2>/dev/null | grep hostnames | grep -o -P "[^\.]*.internal('|\")" | awk -F . '{print $1}' | head -n 1) +# LANDO_APP_DB_NAME=$(printf $LANDO_APP_NAME)_mariadb_1 +# docker container rm --force $LANDO_APP_DB_NAME +# docker volume rm $(printf $LANDO_APP_NAME)_data_mariadb_blank +# docker volume rm $(printf $LANDO_APP_NAME)_data_mariadb_govcms_image +# + ############################################ ## SSH agent volume with pygmy - Optional ## ############################################ @@ -192,7 +204,7 @@ x-environment: &default-environment ## Lando configuration ## ######################### -# Unique lando project name. +# Unique lando project name - uses 'lagoon-project' variable. name: *lagoon-project # Note: Vars only work in the containers, not in the lando.yml files and only if diff --git a/.lando.local.example.yml b/.lando.local.example.yml index 8fe5400..11b7373 100644 --- a/.lando.local.example.yml +++ b/.lando.local.example.yml @@ -29,6 +29,9 @@ x-environment: &default-environment GOVCMS_IMAGE_VERSION: &govcms-image-version 10.x-latest LAGOON_ENVIRONMENT_TYPE: local LOCALDEV_URL: *default-url + # If changing the image via `MARIADB_DATA_IMAGE` AFTER using the lando project, + # then use `lando destroy` or remove one the database volumes via terminal + # commands noted in lando base file. MARIADB_DATA_IMAGE: &MARIADB_DATA_IMAGE govcms/mariadb-drupal:10.x-latest #MARIADB_DATA_IMAGE: &MARIADB_DATA_IMAGE gitlab-registry-production.govcms.amazee.io/org/project/mariadb-drupal-data #STAGE_FILE_PROXY_URL: http://govcms.docker.amazee.io @@ -46,6 +49,9 @@ x-others: - SITE_AUDIT_VERSION: &SITE_AUDIT_VERSION 7.x-3.x - GOVCMS_GITHUB_TOKEN: &GOVCMS_GITHUB_TOKEN '' +# Unique lando project name - uses 'lagoon-project' variable above in same file. +name: *lagoon-project + ############## ## Services ## ############## From e33ffba6f43d37a4e83cba010fdcc44a718cb3ff Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Tue, 23 Apr 2024 14:00:03 +1000 Subject: [PATCH 03/31] Forgot to make govcms version a variable + comment solr by default in the lando example file --- .lando.base.yml | 8 ++++---- .lando.local.example.yml | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index 4c70060..eb376f7 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -131,7 +131,7 @@ proxy: # hostname: {{ GOVCMS_PROJECT_NAME }}-solr.lndo.site:8983 # See GOVCMS_IMAGE_VERSION in "Variables" at https://github.com/govCMS/govCMS/wiki -x-govcms-image-version: &govcms-image-version ${GOVCMS_IMAGE_VERSION:-10.x-latest} +x-govcms-image-version: &govcms-image-version ${GOVCMS_IMAGE_VERSION:-{{ GOVCMS_VERSION }}.x-latest} x-volumes: volumes: @@ -187,7 +187,7 @@ x-environment: &default-environment LAGOON_PROJECT: *lagoon-project LAGOON_ROUTE: *default-url LOCALDEV_URL: *default-url - GOVCMS_IMAGE_VERSION: ${GOVCMS_IMAGE_VERSION:-10.x-latest} + GOVCMS_IMAGE_VERSION: ${GOVCMS_IMAGE_VERSION:-{{ GOVCMS_VERSION }}.x-latest} DEV_MODE: "${DEV_MODE:-false}" XDEBUG_ENABLE: ${XDEBUG_ENABLE:-} DOCKERHOST: ${DOCKERHOST:-host.docker.internal} @@ -389,10 +389,10 @@ services: # Mount the app folder, for db import, db-export. app_mount: true services: - image: ${MARIADB_DATA_IMAGE:-govcms/mariadb-drupal:10.x-latest} + image: ${MARIADB_DATA_IMAGE:-govcms/mariadb-drupal:{{ GOVCMS_VERSION }}.x-latest} labels: lagoon.type: mariadb - lagoon.image: govcms/mariadb-drupal:10.x-latest + lagoon.image: govcms/mariadb-drupal:{{ GOVCMS_VERSION }}.x-latest ports: - '3306' # Find port on host with `docker port [container_name_for_mariadb] 3306` environment: diff --git a/.lando.local.example.yml b/.lando.local.example.yml index 11b7373..0a43797 100644 --- a/.lando.local.example.yml +++ b/.lando.local.example.yml @@ -26,13 +26,13 @@ proxy: x-environment: &default-environment COMPOSE_PROJECT_NAME: *lagoon-project DEV_MODE: true - GOVCMS_IMAGE_VERSION: &govcms-image-version 10.x-latest + GOVCMS_IMAGE_VERSION: &govcms-image-version {{ GOVCMS_VERSION }}.x-latest LAGOON_ENVIRONMENT_TYPE: local LOCALDEV_URL: *default-url # If changing the image via `MARIADB_DATA_IMAGE` AFTER using the lando project, # then use `lando destroy` or remove one the database volumes via terminal # commands noted in lando base file. - MARIADB_DATA_IMAGE: &MARIADB_DATA_IMAGE govcms/mariadb-drupal:10.x-latest + MARIADB_DATA_IMAGE: &MARIADB_DATA_IMAGE govcms/mariadb-drupal:{{ GOVCMS_VERSION }}.x-latest #MARIADB_DATA_IMAGE: &MARIADB_DATA_IMAGE gitlab-registry-production.govcms.amazee.io/org/project/mariadb-drupal-data #STAGE_FILE_PROXY_URL: http://govcms.docker.amazee.io X_FRAME_OPTIONS: SameOrigin @@ -97,10 +97,10 @@ services: image: *MARIADB_DATA_IMAGE environment: << : *default-environment - solr: - services: - build: - args: - GOVCMS_IMAGE_VERSION: *govcms-image-version - environment: - << : *default-environment + # solr: + # services: + # build: + # args: + # GOVCMS_IMAGE_VERSION: *govcms-image-version + # environment: + # << : *default-environment From 9bb5178909dd33d30eac55d1ddb198fe268f24f6 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Tue, 23 Apr 2024 15:54:52 +1000 Subject: [PATCH 04/31] Add lando post setup script to add lando after repo setup. --- scripts/scaffold-init.sh | 1 + scripts/scaffold-post-setup-add-lando.sh | 43 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100755 scripts/scaffold-post-setup-add-lando.sh diff --git a/scripts/scaffold-init.sh b/scripts/scaffold-init.sh index c75d5d4..eb87085 100755 --- a/scripts/scaffold-init.sh +++ b/scripts/scaffold-init.sh @@ -120,5 +120,6 @@ if [[ "$GOVCMS_TYPE" == "saas" ]]; then fi rm scripts/scaffold-init.sh +rm scripts/scaffold-post-setup-add-lando.sh # trap finish EXIT diff --git a/scripts/scaffold-post-setup-add-lando.sh b/scripts/scaffold-post-setup-add-lando.sh new file mode 100755 index 0000000..7d1ebd6 --- /dev/null +++ b/scripts/scaffold-post-setup-add-lando.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# +# Modification script for the GovCMS Scaffold chnage varaibles in lando files. +# + +echo "[info] Preparing Lando GovCMS Scaffold" + +YELLOW='\033[0;33m' +NC='\033[0m' # No Color +printf "I ${RED}love${NC} Stack Overflow\n" + +GOVCMS_NAME=$(grep -oP 'http://\K\w+' docker-compose.yml | head -n 1) +GOVCMS_VERSION=$(grep -oP 'GOVCMS_IMAGE_VERSION:-\K\w+' docker-compose.yml | head -n 1) +grep -q '^ solr:$' docker-compose.yml +HAS_SOLR=$? + +if [[ -z "$GOVCMS_NAME" ]]; then + echo "[error]: Cannot determine GovCMS project name." + exit 2 +fi + +if [[ -z "$GOVCMS_VERSION" ]]; then + echo "[error]: Cannot determine GovCMS version." + exit 2 +fi + +echo "[info]: Modifying scaffold for GovCMS$GOVCMS_VERSION: $GOVCMS_NAME" + +sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" .lando.base.yml && rm .lando.base.yml.bak +sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" .lando.local.example.yml && rm .lando.local.example.yml.bak +sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .lando.base.yml && rm .lando.base.yml.bak +sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .lando.local.example.yml && rm .lando.local.example.yml.bak + +if [[ "$HAS_SOLR" -eq 0 ]]; then + printf "${YELLOW}[!! action required !!]${NC}: SOLR has been detected,\n" + printf "please uncomment the lando SOLR proxy and service in lando.base.yml\n" + printf "and .lando.local[.example].yml files.\n" +fi + +rm scripts/scaffold-post-setup-add-lando.sh + +echo "[success]: Lando GovCMS scaffold changed!" From 16f8a83cb6ed7d0492c04d85dc9504beab43027e Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Tue, 23 Apr 2024 16:09:19 +1000 Subject: [PATCH 05/31] Move lando scripts folder from scripts to "container-scripts" so its not gitignored --- .lando.base.yml | 4 ++-- .lando/container/{scripts => container-scripts}/ahoy-run.sh | 0 .../{scripts => container-scripts}/db-import-prompt.sh | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename .lando/container/{scripts => container-scripts}/ahoy-run.sh (100%) rename .lando/container/{scripts => container-scripts}/db-import-prompt.sh (100%) diff --git a/.lando.base.yml b/.lando.base.yml index eb376f7..2a7d628 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -473,7 +473,7 @@ tooling: 'db-import ': service: ':host' description: 'Imports a dump file into a database service' - cmd: '/lando-govcms/scripts/db-import-prompt.sh /helpers/sql-import.sh' + cmd: '/lando-govcms/container-scripts/db-import-prompt.sh /helpers/sql-import.sh' user: 'root' env: << : *lando-database-tooling-vars @@ -548,7 +548,7 @@ tooling: ahoy-run: service: cli description: Run command inside cli container. - cmd: /lando-govcms/scripts/ahoy-run.sh + cmd: /lando-govcms/container-scripts/ahoy-run.sh ahoy-govcms-deploy: service: cli description: Runs deployment commands (e.g. config import, updb, cr, set up file_stage_proxy). diff --git a/.lando/container/scripts/ahoy-run.sh b/.lando/container/container-scripts/ahoy-run.sh similarity index 100% rename from .lando/container/scripts/ahoy-run.sh rename to .lando/container/container-scripts/ahoy-run.sh diff --git a/.lando/container/scripts/db-import-prompt.sh b/.lando/container/container-scripts/db-import-prompt.sh similarity index 100% rename from .lando/container/scripts/db-import-prompt.sh rename to .lando/container/container-scripts/db-import-prompt.sh From 92f8b9b8e3b1369c12c605e74f8830966fc8d8e6 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Tue, 23 Apr 2024 16:43:31 +1000 Subject: [PATCH 06/31] Add note about .ahoy file being locked in lando change setup script. --- scripts/scaffold-post-setup-add-lando.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/scaffold-post-setup-add-lando.sh b/scripts/scaffold-post-setup-add-lando.sh index 7d1ebd6..86ca360 100755 --- a/scripts/scaffold-post-setup-add-lando.sh +++ b/scripts/scaffold-post-setup-add-lando.sh @@ -38,6 +38,11 @@ if [[ "$HAS_SOLR" -eq 0 ]]; then printf "and .lando.local[.example].yml files.\n" fi +printf "${YELLOW}[!! action required !!]${NC}: For existing projects, you may\n" +printf "need to manually move the changes (new lines) added to the project\n" +printf "root's '.ahoy.yml' file to the 'custom/ahoy.yml' file instead as the file is\n" +printf "govcms locked, commands become 'ahoy my lando-[command]' instead.\n" + rm scripts/scaffold-post-setup-add-lando.sh echo "[success]: Lando GovCMS scaffold changed!" From dee5631b063b532e96a27a8209a77f8ffb8addea Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 8 Apr 2026 17:04:27 +1000 Subject: [PATCH 07/31] Volumes_from is now supported again for SSH --- .lando.base.yml | 63 ++----------------- ....dist.example.with-ssh-external-volume.yml | 26 -------- 2 files changed, 6 insertions(+), 83 deletions(-) delete mode 100644 .lando.dist.example.with-ssh-external-volume.yml diff --git a/.lando.base.yml b/.lando.base.yml index 2a7d628..de9c452 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -25,7 +25,7 @@ # - '[version]': May be '8', '9' or '10' # 2. Enable local overrides by duplicating .lando.local.example.yml to -# .lando.local.yml +# .lando.local.yml (instead of .env file) # Command: `cp -i .lando.local.example.yml .lando.local.yml` @@ -33,11 +33,7 @@ # set MARIADB_DATA_IMAGE or make the lando project name/urls unique for multiple # instances of this same project on the same computer. -# 4. Optional, Enable SSH agent integration with pygmy. - -# See heading in this file 'SSH agent volume with pygmy' for steps. - -# 5. Run the project. +# 4. Run the project. # Command: `lando start` @@ -61,36 +57,6 @@ # docker volume rm $(printf $LANDO_APP_NAME)_data_mariadb_govcms_image # -############################################ -## SSH agent volume with pygmy - Optional ## -############################################ - -# Creating a new SSH agent container is optional for integration, if required -# with pymgy SSH agent. To use, rename -# '.lando.dist.example.with-ssh-external-volume.yml' to .lando.dist.yml', -# rebuild lando and fellow the terminal commands below. - -# Why? -# In Docker compose v3, the' volumes_from' property, which maps volumes from one -# container to another another, cannot be used. The new method, is to specify -# the volume by name, however, the amazee.io SSH agent creates randomly named -# volume, so rename it first. - -# -# OLD_VOLUME=$(docker inspect --type=container --format='{{ (index .Mounts 0).Name }}' amazeeio-ssh-agent) -# docker volume create amazeeio-ssh-agent-volume -# -# docker run --rm -it -v $OLD_VOLUME:/from -v amazeeio-ssh-agent-volume:/to alpine ash -c "cd /from ; cp -av . /to" -# docker run -d --name amazeeio-ssh-agent-new-container \ -# -v amazeeio-ssh-agent-volume:/tmp/amazeeio_ssh-agent \ -# --restart=unless-stopped \ -# pygmystack/ssh-agent -# -# docker container rm amazeeio-ssh-agent -f -# docker rename amazeeio-ssh-agent-new-container amazeeio-ssh-agent -# docker volume rm $OLD_VOLUME -# - ################ ## Misc notes ## ################ @@ -146,14 +112,6 @@ x-volumes-paas: volumes: - &volume-drupal-app .:/app:delegated -# The property, 'volumes_from' was removed in docker compose v3, so use named -# volumes instead. -# Mount volumes from Pygmy to inject host SSH key into container. -# https://pygmy.readthedocs.io/en/master/ssh_agent/ -x-volumes-external: - volumes: - - &volume-ssh-agent amazeeio-ssh-agent-volume:/tmp/amazeeio_ssh-agent - x-volumes-tooling: volumes: - &volume-tooling ./.lando/container:/lando-govcms @@ -167,13 +125,11 @@ x-volumes-with-external: &default-volumes-with-external - *volume-behat-screenshots - *volume-phpunit-tests - *volume-drupal-config - - *volume-ssh-agent - *volume-tooling x-volumes-paas-with-external: &paas-volumes-with-external volumes: - *volume-drupal-app - - *volume-ssh-agent - *volume-tooling # Entry point process isn't PID 1 as lando entrypoint is instead, @@ -224,12 +180,6 @@ x-lando-common-options: &lando-common-options # Do not auto mount /app folder by default. app_mount: false -# Mark volume as internal for each service, use override for external. -x-lando-volumes-top-level: &lando-volumes-top-level - volumes: - amazeeio-ssh-agent-volume: - external: false - x-lando-database-tooling-vars: &lando-database-tooling-vars MYSQL_DATABASE: drupal LANDO_DB_EXPORT_USER: drupal @@ -277,7 +227,6 @@ services: cli: << : *lando-common-options << : *lando-extra-build-steps - << : *lando-volumes-top-level services: build: context: . @@ -299,10 +248,13 @@ services: # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep << : *default-volumes-with-external + # Mount volumes from Pygmy to inject host SSH key into container. + # https://pygmy.readthedocs.io/en/master/ssh_agent/ + volumes_from: + - container:amazeeio-ssh-agent test: << : *lando-common-options - << : *lando-volumes-top-level services: build: context: . @@ -326,7 +278,6 @@ services: nginx: << : *lando-common-options - << : *lando-volumes-top-level # Expose Nginx via lando proxy, note that 'ports' must also be present in # 'services'. moreHttpPorts: @@ -361,7 +312,6 @@ services: php: << : *lando-common-options - << : *lando-volumes-top-level services: build: context: . @@ -447,7 +397,6 @@ services: chrome: << : *lando-common-options - << : *lando-volumes-top-level services: image: selenium/standalone-chrome:4.5.2-20221021 shm_size: '1gb' diff --git a/.lando.dist.example.with-ssh-external-volume.yml b/.lando.dist.example.with-ssh-external-volume.yml deleted file mode 100644 index b9ada32..0000000 --- a/.lando.dist.example.with-ssh-external-volume.yml +++ /dev/null @@ -1,26 +0,0 @@ -######################### -## Lando configuration ## -######################### - -# Mark volume back to external, users need to create external volume though, -# See notes in main lando file. -x-lando-volumes-top-level: &lando-volumes-top-level - volumes: - amazeeio-ssh-agent-volume: - external: true - -############## -## Services ## -############## - -services: - cli: - << : *lando-volumes-top-level - test: - << : *lando-volumes-top-level - nginx: - << : *lando-volumes-top-level - php: - << : *lando-volumes-top-level - chrome: - << : *lando-volumes-top-level From 7e600897dd07299cce504619045888b7c55fc675 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 8 Apr 2026 17:04:56 +1000 Subject: [PATCH 08/31] Comment out .env since we shoudl not use it. --- .lando.base.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index de9c452..3e28857 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -167,8 +167,8 @@ name: *lagoon-project # NOT defined in the .lando.yml files, otherwise lando yml takes precedence, # unlike docker-compose.yml. # @see https://github.com/lando/lando/issues/1616 -env_file: - - .env +#env_file: +# - .env # Define internal/external network 'amazeeio-network'. compose: From fc51605bb183c3e70c0fd616e6909209c33dbd6f Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 8 Apr 2026 17:32:14 +1000 Subject: [PATCH 09/31] align to newest develop --- .lando.base.yml | 38 ++++++++++++++++++++++++++------------ .lando.local.example.yml | 2 -- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index 3e28857..7fdea2c 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -138,6 +138,7 @@ x-extra-environment-tini: &extra-environment-tini - TINI_SUBREAPER: true x-environment: &default-environment + RESTY_RESOLVER: 8.8.8.8 STAGE_FILE_PROXY_URL: ${STAGE_FILE_PROXY_URL:-} LAGOON_ENVIRONMENT_TYPE: ${LAGOON_ENVIRONMENT_TYPE:-} LAGOON_PROJECT: *lagoon-project @@ -152,8 +153,10 @@ x-environment: &default-environment DRUPAL_SHIELD_PASS: ${DRUPAL_SHIELD_PASS:-} GOVCMS_DEPLOY_WORKFLOW_CONFIG: ${GOVCMS_DEPLOY_WORKFLOW_CONFIG:-import} GOVCMS_PREPARE_XML_SCRIPT: /app/vendor/bin/govcms-prepare-xml - CLAMAV_HOST: av - CLAMAV_MODE: daemon + HTTPAV_ENDPOINT: http://av:3993/scan + HTTPAV_RETURN_KEY: comodo + HTTP_PAYLOAD_KEY: malware + SOLR_MODULES: ${SOLR_MODULES:-extraction,langid,ltr,analysis-extras} << : *extra-environment-tini ######################### @@ -240,11 +243,9 @@ services: lagoon.type: cli-persistent lagoon.persistent.name: nginx lagoon.persistent: /app/web/sites/default/files/ + lagoon.base.image: govcms/govcms:${GOVCMS_IMAGE_VERSION:-{{ GOVCMS_VERSION }}.x-latest} environment: << : *default-environment - networks: - - amazeeio-network - - default # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep << : *default-volumes-with-external @@ -263,15 +264,17 @@ services: CLI_IMAGE: *lagoon-project GOVCMS_IMAGE_VERSION: *govcms-image-version SITE_AUDIT_VERSION: ${SITE_AUDIT_VERSION:-7.x-3.x} + # Can't use additional contexts, but lando rebuild pulls new images + # anyway so might not be a problem. + # @see https://github.com/lando/lagoon/pull/107 + # additional_contexts: + # cli: 'service:cli' # Ensure cli is built first labels: lagoon.type: none depends_on: - cli environment: << : *default-environment - networks: - - amazeeio-network - - default # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep << : *default-volumes-with-external @@ -292,6 +295,11 @@ services: args: CLI_IMAGE: *lagoon-project GOVCMS_IMAGE_VERSION: *govcms-image-version + # Can't use additional contexts, but lando rebuild pulls new images + # anyway so might not be a problem. + # @see https://github.com/lando/lagoon/pull/107 + # additional_contexts: + # cli: 'service:cli' # Ensure cli is built first labels: lagoon.type: nginx-php-persistent lagoon.persistent: /app/web/sites/default/files/ @@ -319,6 +327,11 @@ services: args: CLI_IMAGE: *lagoon-project GOVCMS_IMAGE_VERSION: *govcms-image-version + # Can't use additional contexts, but lando rebuild pulls new images + # anyway so might not be a problem. + # @see https://github.com/lando/lagoon/pull/107 + # additional_contexts: + # cli: 'service:cli' # Ensure cli is built first labels: lagoon.type: nginx-php-persistent lagoon.name: nginx @@ -327,9 +340,6 @@ services: - cli environment: << : *default-environment - networks: - - amazeeio-network - - default command: /sbin/tini -- /lagoon/entrypoints.sh /usr/local/sbin/php-fpm -F -R << : *default-volumes-with-external @@ -340,6 +350,7 @@ services: app_mount: true services: image: ${MARIADB_DATA_IMAGE:-govcms/mariadb-drupal:{{ GOVCMS_VERSION }}.x-latest} + platform: linux/amd64 labels: lagoon.type: mariadb lagoon.image: govcms/mariadb-drupal:{{ GOVCMS_VERSION }}.x-latest @@ -385,8 +396,10 @@ services: # dockerfile: .docker/Dockerfile.solr # args: # GOVCMS_IMAGE_VERSION: *govcms-image-version + # LAGOON_IMAGE_VERSION: ${LAGOON_IMAGE_VERSION:-latest} # labels: # lagoon.type: solr + # lagoon.base.image: govcms/solr:${GOVCMS_IMAGE_VERSION:-{{ GOVCMS_VERSION }}.x-latest} # ports: # - '8983' # Find port on host with `docker port [container_name_for_solr] 8983` # depends_on: @@ -399,6 +412,7 @@ services: << : *lando-common-options services: image: selenium/standalone-chrome:4.5.2-20221021 + platform: linux/amd64 shm_size: '1gb' depends_on: - test @@ -606,7 +620,7 @@ tooling: ahoy-ship-shape: service: cli description: Run site validation scripts locally - cmd: shipshape -f /app/vendor/govcms/scaffold-tooling/shipshape.yml --exclude-db --error-code + cmd: shipshape run -f /app/vendor/govcms/scaffold-tooling/shipshape.yml --exclude-db --error-code . ahoy-debug: service: cli description: Enable debug configuration (use alternative command) diff --git a/.lando.local.example.yml b/.lando.local.example.yml index 0a43797..6f6e3b7 100644 --- a/.lando.local.example.yml +++ b/.lando.local.example.yml @@ -46,7 +46,6 @@ x-environment: &default-environment # DRUPAL_SHIELD_PASS: '' x-others: - - SITE_AUDIT_VERSION: &SITE_AUDIT_VERSION 7.x-3.x - GOVCMS_GITHUB_TOKEN: &GOVCMS_GITHUB_TOKEN '' # Unique lando project name - uses 'lagoon-project' variable above in same file. @@ -74,7 +73,6 @@ services: args: CLI_IMAGE: *lagoon-project GOVCMS_IMAGE_VERSION: *govcms-image-version - SITE_AUDIT_VERSION: *SITE_AUDIT_VERSION nginx: services: build: From b6fa95089922bb048b8ba2b490f602c3b4a0b3ee Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Fri, 10 Apr 2026 13:55:27 +1000 Subject: [PATCH 10/31] Rename --- ...-setup-add-lando.sh => scaffold-existing-project-add-lando.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{scaffold-post-setup-add-lando.sh => scaffold-existing-project-add-lando.sh} (100%) diff --git a/scripts/scaffold-post-setup-add-lando.sh b/scripts/scaffold-existing-project-add-lando.sh similarity index 100% rename from scripts/scaffold-post-setup-add-lando.sh rename to scripts/scaffold-existing-project-add-lando.sh From b2be4412b34e4a87daea097087e63460b4d501f7 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Fri, 10 Apr 2026 14:01:43 +1000 Subject: [PATCH 11/31] rename --- scripts/scaffold-existing-project-add-lando.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scaffold-existing-project-add-lando.sh b/scripts/scaffold-existing-project-add-lando.sh index 86ca360..f5221b1 100755 --- a/scripts/scaffold-existing-project-add-lando.sh +++ b/scripts/scaffold-existing-project-add-lando.sh @@ -43,6 +43,6 @@ printf "need to manually move the changes (new lines) added to the project\n" printf "root's '.ahoy.yml' file to the 'custom/ahoy.yml' file instead as the file is\n" printf "govcms locked, commands become 'ahoy my lando-[command]' instead.\n" -rm scripts/scaffold-post-setup-add-lando.sh +rm scripts/scaffold-existing-project-add-lando.sh echo "[success]: Lando GovCMS scaffold changed!" From b05b470cee18f29d35121683ee869f5728a4bd94 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Fri, 10 Apr 2026 14:31:50 +1000 Subject: [PATCH 12/31] TODO "my-project" is "my" instead? --- scripts/scaffold-existing-project-add-lando.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scaffold-existing-project-add-lando.sh b/scripts/scaffold-existing-project-add-lando.sh index f5221b1..be83972 100755 --- a/scripts/scaffold-existing-project-add-lando.sh +++ b/scripts/scaffold-existing-project-add-lando.sh @@ -8,8 +8,8 @@ echo "[info] Preparing Lando GovCMS Scaffold" YELLOW='\033[0;33m' NC='\033[0m' # No Color -printf "I ${RED}love${NC} Stack Overflow\n" +################## TODO "my-project" is "my" instead? GOVCMS_NAME=$(grep -oP 'http://\K\w+' docker-compose.yml | head -n 1) GOVCMS_VERSION=$(grep -oP 'GOVCMS_IMAGE_VERSION:-\K\w+' docker-compose.yml | head -n 1) grep -q '^ solr:$' docker-compose.yml From 8a446497975c87f77f48907a4cac07befb2cc73c Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Mon, 13 Apr 2026 14:32:20 +1000 Subject: [PATCH 13/31] Fix regex for project name detection. --- scripts/scaffold-existing-project-add-lando.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scaffold-existing-project-add-lando.sh b/scripts/scaffold-existing-project-add-lando.sh index be83972..adc3c8b 100755 --- a/scripts/scaffold-existing-project-add-lando.sh +++ b/scripts/scaffold-existing-project-add-lando.sh @@ -10,7 +10,7 @@ YELLOW='\033[0;33m' NC='\033[0m' # No Color ################## TODO "my-project" is "my" instead? -GOVCMS_NAME=$(grep -oP 'http://\K\w+' docker-compose.yml | head -n 1) +GOVCMS_NAME=$(grep -oP 'http:\/\/\K[^\n]+(?=\.docker\.amazee\.io)' docker-compose.yml | head -n 1) GOVCMS_VERSION=$(grep -oP 'GOVCMS_IMAGE_VERSION:-\K\w+' docker-compose.yml | head -n 1) grep -q '^ solr:$' docker-compose.yml HAS_SOLR=$? From 665c12f4b456e877e61b9e6de90c7e5a5fb50daa Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Mon, 13 Apr 2026 14:33:59 +1000 Subject: [PATCH 14/31] Fix name: scaffold-existing-project-add-lando.sh --- scripts/scaffold-init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scaffold-init.sh b/scripts/scaffold-init.sh index fd52bcf..31b71bd 100755 --- a/scripts/scaffold-init.sh +++ b/scripts/scaffold-init.sh @@ -157,6 +157,6 @@ EOF echo "[info]: README.md updated" rm scripts/scaffold-init.sh -rm scripts/scaffold-post-setup-add-lando.sh +rm scripts/scaffold-existing-project-add-lando.sh # trap finish EXIT From cb17eef9d90040f2fa488a1525df8a5f05808c2a Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Mon, 13 Apr 2026 16:26:56 +1000 Subject: [PATCH 15/31] Fix db import recreate database problem. --- .lando.base.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.lando.base.yml b/.lando.base.yml index 7fdea2c..a4d64ac 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -221,6 +221,16 @@ x-lando-extra-build-steps: &lando-extra-build-steps apk add pv && echo -e "\e[96m#### ($LANDO_SERVICE_NAME) PV install done. ####\e[0m"; fi + # If DB container, remove default database paramater, so we can recreate the + # databse without it already existsing. + - | + CONFIG_FILE=/var/lib/mysql/.my.cnf + if test -f $CONFIG_FILE; then + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) DB config file change. ####\e[0m"; + sed -i -e 's|^database=drupal$|#database=drupal|g' $CONFIG_FILE; + echo "Config file: $CONFIG_FILE changed!" + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) DB config file change done. ####\e[0m"; + fi ############## ## Services ## @@ -358,6 +368,11 @@ services: - '3306' # Find port on host with `docker port [container_name_for_mariadb] 3306` environment: << : *default-environment + # Govcms database name for lando sql import script, instead of + # `~/.my.cnf` + MYSQL_DATABASE: drupal + # GovCMS SQL container doesn't allow TCP/IP connections. + LANDO_EXTRA_DB_IMPORT_ARGS: --socket=/run/mysqld/mysqld.sock command: /sbin/tini -- /lagoon/entrypoints.bash mysqld # Keep index data across lando rebuilds. (1 of 2) volumes: From d255465068a9cb7705e1a3f33583680e36c31582 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Mon, 13 Apr 2026 17:20:38 +1000 Subject: [PATCH 16/31] Avoid sandbox comment due to different client versions on cli vs mariadb containers. --- .../container/container-scripts/db-import-prompt.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.lando/container/container-scripts/db-import-prompt.sh b/.lando/container/container-scripts/db-import-prompt.sh index 710666c..13c9d25 100755 --- a/.lando/container/container-scripts/db-import-prompt.sh +++ b/.lando/container/container-scripts/db-import-prompt.sh @@ -4,6 +4,19 @@ set -e # Get the lando logger . /helpers/log.sh +mysql() { + # Avoid sandbox comment due to different client versions on cli vs mariadb + # containers. + # @see https://github.com/govCMS/scaffold/issues/133 + if ! test -t 0; then + awk 'NR == 1 && /\/\*M\!999999\\\- enable the sandbox mode \*\// {next} {print}' | command mysql "$@" + else + command mysql "$@" + fi +} +# Pass to sub bash script. +export -f mysql + echo "Do you really want to import the database file? (yes/no) [no]:" read -r -p " > " response; if [ ! "${response}" = "y" ] && [ ! "${response}" = "yes" ]; then From e4cb5011ddb5e664970d0d4ad404a269954b921b Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Tue, 14 Apr 2026 16:03:52 +1000 Subject: [PATCH 17/31] move lando args --- .lando.base.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index a4d64ac..76dfac8 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -184,6 +184,8 @@ x-lando-common-options: &lando-common-options app_mount: false x-lando-database-tooling-vars: &lando-database-tooling-vars + # Govcms database name for lando sql import script, instead of + # `~/.my.cnf` MYSQL_DATABASE: drupal LANDO_DB_EXPORT_USER: drupal LANDO_DB_IMPORT_USER: drupal @@ -192,7 +194,8 @@ x-lando-database-tooling-vars: &lando-database-tooling-vars # but the default lando script places the extra paramters at the end, so use # the druapl user. LANDO_EXTRA_DB_EXPORT_ARGS: -pdrupal --single-transaction - LANDO_EXTRA_DB_IMPORT_ARGS: -pdrupal + # GovCMS SQL container doesn't allow TCP/IP connections. + LANDO_EXTRA_DB_IMPORT_ARGS: -pdrupal --socket=/run/mysqld/mysqld.sock --disable-ssl x-lando-tooling-mysql-cmd: &lando-mysql-cli-cmd 'mysql -udrupal -pdrupal -h 127.0.0.1 drupal' @@ -368,11 +371,6 @@ services: - '3306' # Find port on host with `docker port [container_name_for_mariadb] 3306` environment: << : *default-environment - # Govcms database name for lando sql import script, instead of - # `~/.my.cnf` - MYSQL_DATABASE: drupal - # GovCMS SQL container doesn't allow TCP/IP connections. - LANDO_EXTRA_DB_IMPORT_ARGS: --socket=/run/mysqld/mysqld.sock command: /sbin/tini -- /lagoon/entrypoints.bash mysqld # Keep index data across lando rebuilds. (1 of 2) volumes: From f07d1ca2993be81643de21019340324cade09c40 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Tue, 14 Apr 2026 16:16:18 +1000 Subject: [PATCH 18/31] Add newest mysql client work around. --- .lando.base.yml | 24 +++++++++++++++++++ .../container-scripts/db-import-prompt.sh | 14 ++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index 76dfac8..867472b 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -234,6 +234,30 @@ x-lando-extra-build-steps: &lando-extra-build-steps echo "Config file: $CONFIG_FILE changed!" echo -e "\e[96m#### ($LANDO_SERVICE_NAME) DB config file change done. ####\e[0m"; fi + # Download another copy of mariadb-client to avoid sandbox uncomment hack. + - | + if command -v mariadb > /dev/null; then + PROGRAM=mariadb-client + # Same repo as cli image. + REPO=https://dl-cdn.alpinelinux.org/alpine/v3.23/main + apkInstalledVersion() { + apk info "$1" | head -n1 | sed "s/^$1-\(.*\) description:/\1/g" + } + apkSearchVersion() { + apk search $1 --no-cache --repository $REPO | grep "^$1-\d\+" | head -n1 | sed "s/^$1-//" + } + CURRENT_VERSION=$(apkInstalledVersion $PROGRAM) + SEARCH_VERSION=$(apkSearchVersion $PROGRAM) + if [ $(printf "${CURRENT_VERSION}\n${SEARCH_VERSION}"|sort|head -1) == "${CURRENT_VERSION}" ]; then + echo "Newest version of $PROGRAM required, downloading..." + mkdir "/opt/custom-${PROGRAM}" + wget -q --show-progress "${REPO}/$(arch)/${PROGRAM}-${SEARCH_VERSION}.apk" -O "/opt/custom-${PROGRAM}/${PROGRAM}.apk" + tar -xzf "/opt/custom-${PROGRAM}/${PROGRAM}.apk" -C "/opt/custom-${PROGRAM}" + echo "Downloaded and extracted ${PROGRAM}@${SEARCH_VERSION} to /opt/custom-${PROGRAM}." + else + echo "Newest version of $PROGRAM is already installed." + fi + fi ############## ## Services ## diff --git a/.lando/container/container-scripts/db-import-prompt.sh b/.lando/container/container-scripts/db-import-prompt.sh index 13c9d25..153076f 100755 --- a/.lando/container/container-scripts/db-import-prompt.sh +++ b/.lando/container/container-scripts/db-import-prompt.sh @@ -8,10 +8,18 @@ mysql() { # Avoid sandbox comment due to different client versions on cli vs mariadb # containers. # @see https://github.com/govCMS/scaffold/issues/133 - if ! test -t 0; then - awk 'NR == 1 && /\/\*M\!999999\\\- enable the sandbox mode \*\// {next} {print}' | command mysql "$@" + CUSTOM_MARIADB_PROGRAM=/opt/custom-mariadb-client/usr/bin/mariadb + # Try to use our newest download version. + if test -f $CUSTOM_MARIADB_PROGRAM; then + "$CUSTOM_MARIADB_PROGRAM" "$@" + # Else use hack to remove sandbox comment. else - command mysql "$@" + # If std-input, then change it. + if ! test -t 0; then + awk 'NR == 1 && /\/\*M\!999999\\\- enable the sandbox mode \*\// {next} {print}' | command mysql "$@" + else + command mysql "$@" + fi fi } # Pass to sub bash script. From c49e990e7dd7bf00c277dba2c0df91ffc0ee14cc Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Tue, 14 Apr 2026 16:28:11 +1000 Subject: [PATCH 19/31] Add ($LANDO_SERVICE_NAME) Mariadb client download. --- .lando.base.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.lando.base.yml b/.lando.base.yml index 867472b..ea06263 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -237,6 +237,7 @@ x-lando-extra-build-steps: &lando-extra-build-steps # Download another copy of mariadb-client to avoid sandbox uncomment hack. - | if command -v mariadb > /dev/null; then + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) Mariadb client download. ####\e[0m"; PROGRAM=mariadb-client # Same repo as cli image. REPO=https://dl-cdn.alpinelinux.org/alpine/v3.23/main @@ -257,6 +258,7 @@ x-lando-extra-build-steps: &lando-extra-build-steps else echo "Newest version of $PROGRAM is already installed." fi + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) Mariadb client download done. ####\e[0m"; fi ############## From b8bdefd934ca8d631d3327ea45485eb29a8b04c7 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Tue, 14 Apr 2026 17:52:55 +1000 Subject: [PATCH 20/31] Reset .ahoy.yml back to default and add lando ahoy file. --- .ahoy.yml | 152 ------------------------------------------ custom/ahoy.lando.yml | 152 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+), 152 deletions(-) create mode 100644 custom/ahoy.lando.yml diff --git a/.ahoy.yml b/.ahoy.yml index 3b48da2..434aeff 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -156,155 +156,3 @@ commands: init: usage: Initialise codebase with project name, type (saas|paas|saasplus) and version (8|9) cmd: scripts/scaffold-init.sh -n $1 -t $2 -v $3 - - ##################### - ## Lando commands ### - ##################### - lando: - service: cli - cmd: echo Use \`ahoy lando-[command]\` to run specific ahoy lando commands instead. - - lando-up: - usage: Build project. [Lando] - cmd: | - lando start "$@" && - ahoy lando-info; - - lando-down: - usage: Delete project (CAUTION). [Lando] - # `lando destroy` already has a prompt. - cmd: lando destroy - - lando-build: - usage: Build project. [Lando] - cmd: | - lando rebuild "$@" - ahoy lando-govcms-deploy && ahoy lando-info; - - lando-cli: - usage: Start a shell inside cli container. [Lando] - cmd: lando ssh -s cli - - lando-run: - usage: Run command inside cli container. [Lando] - cmd: docker exec -it $(ahoy lando-app-name)_cli_1 bash -c "$*" - - lando-govcms-deploy: - usage: Runs deployment commands (e.g. config import, updb, cr, set up file_stage_proxy). [lando] - cmd: | - lando ssh -s cli -c "mkdir -p /app/web/sites/default/files/private/tmp && \ - /app/vendor/bin/govcms-db-update && \ - /app/vendor/bin/govcms-config-import && \ - /app/vendor/bin/govcms-cache-rebuild && \ - /app/vendor/bin/govcms-enable_modules" - - lando-drush: - usage: Run drush commands in cli container. [Lando] - cmd: lando drush "$@" - - lando-logs: - usage: Show Docker logs. [Lando] - cmd: lando logs "$@" - - lando-ps: - usage: List running Docker containers. [Lando] - # Find Lando app name and pass to docker docker container ls - cmd: ahoy lando-app-name | { read result; head -1; docker container ls -a | grep $result; } - - lando-restart: - usage: Restart Docker containers. [Lando] - cmd: lando restart - - lando-stop: - usage: Stop Docker containers. [Lando] - cmd: lando stop "$@" - - lando-install: - usage: Install the profile. [Lando] - cmd: | - ahoy confirm "Running this command will destroy your current site, are you sure?" && \ - (lando ssh -u 0 -s cli -c "drush si -y govcms \"$@\"" && ahoy lando-govcms-deploy) || \ - echo "Cancelled." - - lando-login: - usage: Login to a website. [Lando] - cmd: | - lando ssh -s cli -c "drush -y cset tfa.settings reset_pass_skip_enabled true" && \ - lando ssh -s cli -c "drush uinf --uid 1 --field name" | xargs -I % lando ssh -s cli -c "drush uublk %" && \ - lando ssh -s cli -c "drush uli" - - lando-unloop: - usage: Fix local redirect loop [Lando] - # Make the PHP code, escape it and run in docker not lando due to issue - # lando/lando#212 - cmd: | - DRUSH_TEMP_COMMAND=$(cat <<'END' - $u=\Drupal\user\Entity\User::load(1); $u->set("field_password_expiration", "0"); $u->save(); - $u=\Drupal\user\Entity\User::load(1); $u->set("field_last_password_reset", date("Y-m-d\TH:i:s")); $u->save(); - END - ); DRUSH_TEMP_COMMAND="$(printf "\"%q\"" $DRUSH_TEMP_COMMAND)" - docker exec -it $(ahoy lando-app-name)_cli_1 bash -c "drush ev \"$DRUSH_TEMP_COMMAND\"" - - lando-mysql-import: - usage: Pipe in a sql file. `ahoy lando-mysql-import local.sql` [Lando] - cmd: | - if [ -e "$@" ] ; then - lando ssh -s cli -c 'drush sql-drop' && - lando ssh -s cli -c 'drush sql-cli' < "$@" - else echo "Provided sql file" "$@" "does not exist" - fi - - lando-mysql-dump: - usage: Dump data out into a file. `ahoy lando-mysql-dump local.sql` [Lando] - cmd: lando ssh -s cli -c 'drush sql-dump --ordered-dump' > "$@" - - lando-lint: - usage: Lint code [Lando] - cmd: | - lando ssh -s test -c ./vendor/bin/govcms-lint web/modules/custom - lando ssh -s test -c ./vendor/bin/govcms-lint web/themes/custom - - lando-test-behat: - usage: Run Behat tests. [Lando] - cmd: lando ssh -s test -c ./vendor/bin/govcms-behat "$@" - - lando-test-phpunit: - usage: Run phpunit tests [Lando] - cmd: lando ssh -s test -c ./vendor/bin/govcms-phpunit --testsuite govcms - - lando-refresh-db: - usage: Refresh the database container with latest nightly dump. [Lando] - cmd: | - ahoy confirm "Running this command will replace your current database. Are you sure?" && - ( cat .env | grep ^MARIADB_DATA_IMAGE | cut -c20- \ - | xargs -n1 docker pull; docker rm -f -v $(ahoy lando-app-name)_mariadb_1 \ - && lando start ) || - echo OK, probably a wise choice... - - lando-ship-shape: - usage: Run site validation scripts locally [Lando] - cmd: | - docker exec -it $(ahoy lando-app-name)_cli_1 bash -c "shipshape -f /app/vendor/govcms/scaffold-tooling/shipshape.yml --exclude-db --error-code \"$@\"" - - lando-debug: - usage: Enable debug configuration. [Lando] - cmd: | - { ahoy lando-run "php -v|grep -q Xdebug" && echo "Debug is already enabled. Use \`export XDEBUG_ENABLE="" && lando rebuild\` to disable."; } \ - || { export XDEBUG_ENABLE="true" && lando rebuild && \ - ahoy lando-run "php -v|grep -q Xdebug" && echo "Enabled debug configuration. Use \`export XDEBUG_ENABLE="" && lando rebuild\` to disable." || \ - echo "Enabling debug configuration failed."; } - - lando-info: - usage: Print information about this project. [Lando] - cmd: | - echo "Project : "$(ahoy lando-run "echo \$LAGOON_PROJECT" 2>/dev/null) - echo "Site local URL : "$(ahoy lando-run "echo \$LAGOON_ROUTE" 2>/dev/null) - echo "DB port on host : "$(docker port $(ahoy lando-app-name 2>/dev/null)_mariadb_1 3306 | cut -d : -f 2) - if [ "$1" ]; then - echo "One-time login : " $(ahoy lando-login -- --no-browser) - fi - - # Helpers. - lando-app-name: - cmd: lando info 2>/dev/null | grep hostnames | grep -o -P "[^\.]*.internal('|\")" | awk -F . '{print $1}' | head -n 1 - hide: true diff --git a/custom/ahoy.lando.yml b/custom/ahoy.lando.yml new file mode 100644 index 0000000..36b4ecd --- /dev/null +++ b/custom/ahoy.lando.yml @@ -0,0 +1,152 @@ + # Example file to copy and paste into custom/ahoy.yml. + ##################### + ## Lando commands ### + ##################### + lando: + service: cli + cmd: echo Use \`ahoy lando-[command]\` to run specific ahoy lando commands instead. + + lando-up: + usage: Build project. [Lando] + cmd: | + lando start "$@" && + ahoy lando-info; + + lando-down: + usage: Delete project (CAUTION). [Lando] + # `lando destroy` already has a prompt. + cmd: lando destroy + + lando-build: + usage: Build project. [Lando] + cmd: | + lando rebuild "$@" + ahoy lando-govcms-deploy && ahoy lando-info; + + lando-cli: + usage: Start a shell inside cli container. [Lando] + cmd: lando ssh -s cli + + lando-run: + usage: Run command inside cli container. [Lando] + cmd: docker exec -it $(ahoy lando-app-name)_cli_1 bash -c "$*" + + lando-govcms-deploy: + usage: Runs deployment commands (e.g. config import, updb, cr, set up file_stage_proxy). [lando] + cmd: | + lando ssh -s cli -c "mkdir -p /app/web/sites/default/files/private/tmp && \ + /app/vendor/bin/govcms-db-update && \ + /app/vendor/bin/govcms-config-import && \ + /app/vendor/bin/govcms-cache-rebuild && \ + /app/vendor/bin/govcms-enable_modules" + + lando-drush: + usage: Run drush commands in cli container. [Lando] + cmd: lando drush "$@" + + lando-logs: + usage: Show Docker logs. [Lando] + cmd: lando logs "$@" + + lando-ps: + usage: List running Docker containers. [Lando] + # Find Lando app name and pass to docker docker container ls + cmd: ahoy lando-app-name | { read result; head -1; docker container ls -a | grep $result; } + + lando-restart: + usage: Restart Docker containers. [Lando] + cmd: lando restart + + lando-stop: + usage: Stop Docker containers. [Lando] + cmd: lando stop "$@" + + lando-install: + usage: Install the profile. [Lando] + cmd: | + ahoy confirm "Running this command will destroy your current site, are you sure?" && \ + (lando ssh -u 0 -s cli -c "drush si -y govcms \"$@\"" && ahoy lando-govcms-deploy) || \ + echo "Cancelled." + + lando-login: + usage: Login to a website. [Lando] + cmd: | + lando ssh -s cli -c "drush -y cset tfa.settings reset_pass_skip_enabled true" && \ + lando ssh -s cli -c "drush uinf --uid 1 --field name" | xargs -I % lando ssh -s cli -c "drush uublk %" && \ + lando ssh -s cli -c "drush uli" + + lando-unloop: + usage: Fix local redirect loop [Lando] + # Make the PHP code, escape it and run in docker not lando due to issue + # lando/lando#212 + cmd: | + DRUSH_TEMP_COMMAND=$(cat <<'END' + $u=\Drupal\user\Entity\User::load(1); $u->set("field_password_expiration", "0"); $u->save(); + $u=\Drupal\user\Entity\User::load(1); $u->set("field_last_password_reset", date("Y-m-d\TH:i:s")); $u->save(); + END + ); DRUSH_TEMP_COMMAND="$(printf "\"%q\"" $DRUSH_TEMP_COMMAND)" + docker exec -it $(ahoy lando-app-name)_cli_1 bash -c "drush ev \"$DRUSH_TEMP_COMMAND\"" + + lando-mysql-import: + usage: Pipe in a sql file. `ahoy lando-mysql-import local.sql` [Lando] + cmd: | + if [ -e "$@" ] ; then + lando ssh -s cli -c 'drush sql-drop' && + lando ssh -s cli -c 'drush sql-cli' < "$@" + else echo "Provided sql file" "$@" "does not exist" + fi + + lando-mysql-dump: + usage: Dump data out into a file. `ahoy lando-mysql-dump local.sql` [Lando] + cmd: lando ssh -s cli -c 'drush sql-dump --ordered-dump' > "$@" + + lando-lint: + usage: Lint code [Lando] + cmd: | + lando ssh -s test -c ./vendor/bin/govcms-lint web/modules/custom + lando ssh -s test -c ./vendor/bin/govcms-lint web/themes/custom + + lando-test-behat: + usage: Run Behat tests. [Lando] + cmd: lando ssh -s test -c ./vendor/bin/govcms-behat "$@" + + lando-test-phpunit: + usage: Run phpunit tests [Lando] + cmd: lando ssh -s test -c ./vendor/bin/govcms-phpunit --testsuite govcms + + lando-refresh-db: + usage: Refresh the database container with latest nightly dump. [Lando] + cmd: | + ahoy confirm "Running this command will replace your current database. Are you sure?" && + ( cat .env | grep ^MARIADB_DATA_IMAGE | cut -c20- \ + | xargs -n1 docker pull; docker rm -f -v $(ahoy lando-app-name)_mariadb_1 \ + && lando start ) || + echo OK, probably a wise choice... + + lando-ship-shape: + usage: Run site validation scripts locally [Lando] + cmd: | + docker exec -it $(ahoy lando-app-name)_cli_1 bash -c "shipshape -f /app/vendor/govcms/scaffold-tooling/shipshape.yml --exclude-db --error-code \"$@\"" + + lando-debug: + usage: Enable debug configuration. [Lando] + cmd: | + { ahoy lando-run "php -v|grep -q Xdebug" && echo "Debug is already enabled. Use \`export XDEBUG_ENABLE="" && lando rebuild\` to disable."; } \ + || { export XDEBUG_ENABLE="true" && lando rebuild && \ + ahoy lando-run "php -v|grep -q Xdebug" && echo "Enabled debug configuration. Use \`export XDEBUG_ENABLE="" && lando rebuild\` to disable." || \ + echo "Enabling debug configuration failed."; } + + lando-info: + usage: Print information about this project. [Lando] + cmd: | + echo "Project : "$(ahoy lando-run "echo \$LAGOON_PROJECT" 2>/dev/null) + echo "Site local URL : "$(ahoy lando-run "echo \$LAGOON_ROUTE" 2>/dev/null) + echo "DB port on host : "$(docker port $(ahoy lando-app-name 2>/dev/null)_mariadb_1 3306 | cut -d : -f 2) + if [ "$1" ]; then + echo "One-time login : " $(ahoy lando-login -- --no-browser) + fi + + # Helpers. + lando-app-name: + cmd: lando info 2>/dev/null | grep hostnames | grep -o -P "[^\.]*.internal('|\")" | awk -F . '{print $1}' | head -n 1 + hide: true From c1907d8bc444e89f9498192c55cc8160b78767f1 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 15 Apr 2026 12:52:30 +1000 Subject: [PATCH 21/31] Add more notes to lando.base.yml file. --- .lando.base.yml | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index ea06263..a986f5d 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -2,7 +2,7 @@ ## Instructions ## ################## -# This file is designed to be used with an alternative docker-compose wrappe +# This file is designed to be used with an alternative docker-compose wrapper # tool 'lando'. Installation instructions for the tool can be found here: # - Mac OS - https://docs.lando.dev/install/macos.html # - Linux OS - https://docs.lando.dev/install/linux.html @@ -10,24 +10,18 @@ # --- (for best performance, install the full docker desktop in windows with WSL # intergration, then the install lando in the WSL via the `caveats` way. -# 1. Initialise the project, if not already done -# (skip this step if this project has already been provided by govcms, ahoy -# command fails or file '[project]/scripts/scaffold-init.sh' does not exist.) +# 1. After the initialising the project, (may have already been done is by +# GovCMS if '[project]/scripts/scaffold-init.sh' doesn't exist): +# Run '[project]/scripts/scaffold-existing-project-add-lando.sh'. -# Command: -# `ahoy init [project_name] [type] [version]` -# OR -# `./scripts/scaffold-init.sh -n [project_name] -t [type] -v [version]` +# Command `./scripts/scaffold-existing-project-add-lando.sh` -# Where: -# - '[project_name]': Is your project name -# - '[type]': May be 'saas' or 'paas' -# - '[version]': May be '8', '9' or '10' +# 2. Optionally enable local overrides (e.g. change project name for multiple +# copies of the same project running at once) by duplicating +# '[project]/.lando.local.example.yml' to '[project].lando.local.yml' +# (instead of .env file): -# 2. Enable local overrides by duplicating .lando.local.example.yml to -# .lando.local.yml (instead of .env file) - -# Command: `cp -i .lando.local.example.yml .lando.local.yml` +# Command: `cp -i ./.lando.local.example.yml ./.lando.local.yml` # 3. Adjust '.lando.local.yml' if required. For example, toggle DEV_MODE, # set MARIADB_DATA_IMAGE or make the lando project name/urls unique for multiple @@ -57,6 +51,25 @@ # docker volume rm $(printf $LANDO_APP_NAME)_data_mariadb_govcms_image # +################### +## Ahoy commands ## +################### + +# Out of the box, ahoy commands in lando are mapped like: +# `ahoy [command]` +# becomes +# `lando ahoy-[command]` + +# If you prefer to use ahoy directly, then first copy the content of: +# [project]/custom/ahoy.lando.yml +# to: +# [project]/custom/ahoy.yml +# +# then the commands are: +# `ahoy [command]` +# becomes +# ahoy my lando-[command] + ################ ## Misc notes ## ################ From f7d89020d426e369453e490709fa1115a7275f06 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 15 Apr 2026 12:53:42 +1000 Subject: [PATCH 22/31] Revert `scaffold-init.sh` as unlikely to me maerged so create lando as and add on. --- scripts/scaffold-init.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/scaffold-init.sh b/scripts/scaffold-init.sh index 31b71bd..f91fe13 100755 --- a/scripts/scaffold-init.sh +++ b/scripts/scaffold-init.sh @@ -58,16 +58,10 @@ echo "[info]: Preparing scaffold for GovCMS$GOVCMS_VERSION ($GOVCMS_TYPE): $GOVC cp .env.default .env sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" .env && rm .env.bak sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" docker-compose.yml && rm docker-compose.yml.bak -sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" .lando.base.yml && rm .lando.base.yml.bak -sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" .lando.local.example.yml && rm .lando.local.example.yml.bak sed -i.bak "s/{{ GOVCMS_TYPE }}/$GOVCMS_TYPE/" .version.yml && rm .version.yml.bak sed -i.bak "s/{{ GOVCMS_TYPE }}/$GOVCMS_TYPE/" docker-compose.yml && rm docker-compose.yml.bak -sed -i.bak "s/{{ GOVCMS_TYPE }}/$GOVCMS_TYPE/" .lando.base.yml && rm .lando.base.yml.bak -sed -i.bak "s/{{ GOVCMS_TYPE }}/$GOVCMS_TYPE/" .lando.local.example.yml && rm .lando.local.example.yml.bak sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .version.yml && rm .version.yml.bak sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" docker-compose.yml && rm docker-compose.yml.bak -sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .lando.base.yml && rm .lando.base.yml.bak -sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .lando.local.example.yml && rm .lando.local.example.yml.bak sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .env && rm .env.bak sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .docker/Dockerfile* && rm .docker/Dockerfile*.bak @@ -88,7 +82,6 @@ else # Replace default/saas mounts for PaaS projects. sed -i.bak "s/*default-volumes/*paas-volumes/" docker-compose.yml && rm docker-compose.yml.bak - sed -i.bak "s/*default-volumes/*paas-volumes/" .lando.base.yml && rm .lando.base.yml.bak # Copy correct composer.json version into place. cp "composer.$GOVCMS_VERSION.json" composer.json @@ -157,6 +150,5 @@ EOF echo "[info]: README.md updated" rm scripts/scaffold-init.sh -rm scripts/scaffold-existing-project-add-lando.sh # trap finish EXIT From 510c5cb3b5cfb414e97b59ef34da81561b94393b Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 15 Apr 2026 13:00:51 +1000 Subject: [PATCH 23/31] Change note about optional - ahoy in init file. --- scripts/scaffold-existing-project-add-lando.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/scaffold-existing-project-add-lando.sh b/scripts/scaffold-existing-project-add-lando.sh index adc3c8b..284c79b 100755 --- a/scripts/scaffold-existing-project-add-lando.sh +++ b/scripts/scaffold-existing-project-add-lando.sh @@ -33,15 +33,13 @@ sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .lando.base.yml && rm .land sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .lando.local.example.yml && rm .lando.local.example.yml.bak if [[ "$HAS_SOLR" -eq 0 ]]; then - printf "${YELLOW}[!! action required !!]${NC}: SOLR has been detected,\n" + printf "\n${YELLOW}[!! action required !!]${NC}: SOLR has been detected,\n" printf "please uncomment the lando SOLR proxy and service in lando.base.yml\n" - printf "and .lando.local[.example].yml files.\n" + printf "and .lando.local[.example].yml files.\n\n" fi -printf "${YELLOW}[!! action required !!]${NC}: For existing projects, you may\n" -printf "need to manually move the changes (new lines) added to the project\n" -printf "root's '.ahoy.yml' file to the 'custom/ahoy.yml' file instead as the file is\n" -printf "govcms locked, commands become 'ahoy my lando-[command]' instead.\n" +printf "\n${YELLOW}[!! optional - ahoy !!]${NC}:\n" +printf "If you would like .ahoy.yml integration, see notes in .lando.base.yml.\n\n" rm scripts/scaffold-existing-project-add-lando.sh From 4cd360af4f38edcae1dd6ab6ccbd711e51080ac8 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 15 Apr 2026 14:04:43 +1000 Subject: [PATCH 24/31] Add meUser so cli containers use drush in root home folder. --- .lando.base.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.lando.base.yml b/.lando.base.yml index a986f5d..fd62ad5 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -282,6 +282,7 @@ services: cli: << : *lando-common-options << : *lando-extra-build-steps + meUser: root services: build: context: . @@ -308,6 +309,7 @@ services: test: << : *lando-common-options + meUser: root services: build: context: . @@ -333,6 +335,7 @@ services: nginx: << : *lando-common-options + meUser: root # Expose Nginx via lando proxy, note that 'ports' must also be present in # 'services'. moreHttpPorts: @@ -372,6 +375,7 @@ services: php: << : *lando-common-options + meUser: root services: build: context: . @@ -398,6 +402,7 @@ services: mariadb: << : *lando-common-options << : *lando-extra-build-steps + meUser: mysql # Mount the app folder, for db import, db-export. app_mount: true services: @@ -425,6 +430,7 @@ services: command: mysql -uroot --silent --execute "SHOW DATABASES;" av: << : *lando-common-options + meUser: root services: image: govcms/av:latest labels: @@ -436,6 +442,7 @@ services: # Uncomment to enable solr and `proxy` => `solr`. # solr: # << : *lando-common-options + # meUser: solr # # Expose SOLR via lando proxy. # moreHttpPorts: # - '8983' @@ -462,6 +469,7 @@ services: chrome: << : *lando-common-options + meUser: seluser services: image: selenium/standalone-chrome:4.5.2-20221021 platform: linux/amd64 From f2cb83321010e1a1b2fc8b45703c133ace248bab Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 15 Apr 2026 15:22:31 +1000 Subject: [PATCH 25/31] Add disable ssl to mariadb client on cli container. --- .lando.base.yml | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index fd62ad5..5794aa7 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -229,13 +229,13 @@ x-lando-extra-build-steps: &lando-extra-build-steps # Add pv. - | if apk list | grep "{pv}" > /dev/null | grep -q pv; then - # Run this if confirm returns true. - echo -e "\e[96m#### ($LANDO_SERVICE_NAME) PV is already installed. ####\e[0m"; - else - # Run this if confirm returns false. - echo -e "\e[96m#### ($LANDO_SERVICE_NAME) Installing PV. ####\e[0m" && - apk add pv && - echo -e "\e[96m#### ($LANDO_SERVICE_NAME) PV install done. ####\e[0m"; + # Run this if confirm returns true. + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) PV is already installed. ####\e[0m"; + else + # Run this if confirm returns false. + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) Installing PV. ####\e[0m" && + apk add pv && + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) PV install done. ####\e[0m"; fi # If DB container, remove default database paramater, so we can recreate the # databse without it already existsing. @@ -273,6 +273,18 @@ x-lando-extra-build-steps: &lando-extra-build-steps fi echo -e "\e[96m#### ($LANDO_SERVICE_NAME) Mariadb client download done. ####\e[0m"; fi + # Disable SSL on mariadb client. Note that drush uses it's own mysql + # configuration instead. Also, the drush.yml extra paramater is not used on + # drush v12 for site install, so use work around of + # `composer require "drush/drush:13.6.2 as 12.5.2" -W` in cli container. + # @see https://github.com/uselagoon/lagoon-images/pull/1276 + # @see https://github.com/govCMS/scaffold/issues/133#issuecomment-4249427842 + - | + if test -d /etc/my.cnf.d; then + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) Disable SSL on mariadb client. ####\e[0m"; + printf '[client]\nskip-ssl' > /etc/my.cnf.d/zz-mariadb-client.cnf + echo -e "\e[96m#### ($LANDO_SERVICE_NAME) Disable SSL on mariadb client - done. ####\e[0m"; + fi ############## ## Services ## From e24d309a2ac34807d8ccad34ef7729122e2899a7 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 15 Apr 2026 15:22:52 +1000 Subject: [PATCH 26/31] Spelling: database --- .lando.base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lando.base.yml b/.lando.base.yml index 5794aa7..579c4f1 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -238,7 +238,7 @@ x-lando-extra-build-steps: &lando-extra-build-steps echo -e "\e[96m#### ($LANDO_SERVICE_NAME) PV install done. ####\e[0m"; fi # If DB container, remove default database paramater, so we can recreate the - # databse without it already existsing. + # database without it already existsing. - | CONFIG_FILE=/var/lib/mysql/.my.cnf if test -f $CONFIG_FILE; then From f060947ab873ecdb1c699e082050f7818d32b46f Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 15 Apr 2026 19:10:36 +1000 Subject: [PATCH 27/31] Add user for lando ssh, remove progress on wget as different version support --- .lando.base.yml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index 579c4f1..6de70ac 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -262,10 +262,13 @@ x-lando-extra-build-steps: &lando-extra-build-steps } CURRENT_VERSION=$(apkInstalledVersion $PROGRAM) SEARCH_VERSION=$(apkSearchVersion $PROGRAM) - if [ $(printf "${CURRENT_VERSION}\n${SEARCH_VERSION}"|sort|head -1) == "${CURRENT_VERSION}" ]; then + echo "Version compare:" + echo "Current: $CURRENT_VERSION" + echo "Search: $SEARCH_VERSION" + if [ $(printf "${CURRENT_VERSION}\n${SEARCH_VERSION}"|sort -r|head -1) != "${CURRENT_VERSION}" ]; then echo "Newest version of $PROGRAM required, downloading..." mkdir "/opt/custom-${PROGRAM}" - wget -q --show-progress "${REPO}/$(arch)/${PROGRAM}-${SEARCH_VERSION}.apk" -O "/opt/custom-${PROGRAM}/${PROGRAM}.apk" + wget -q "${REPO}/$(arch)/${PROGRAM}-${SEARCH_VERSION}.apk" -O "/opt/custom-${PROGRAM}/${PROGRAM}.apk" tar -xzf "/opt/custom-${PROGRAM}/${PROGRAM}.apk" -C "/opt/custom-${PROGRAM}" echo "Downloaded and extracted ${PROGRAM}@${SEARCH_VERSION} to /opt/custom-${PROGRAM}." else @@ -294,8 +297,8 @@ services: cli: << : *lando-common-options << : *lando-extra-build-steps - meUser: root services: + user: root build: context: . dockerfile: .docker/Dockerfile.cli @@ -311,6 +314,7 @@ services: lagoon.base.image: govcms/govcms:${GOVCMS_IMAGE_VERSION:-{{ GOVCMS_VERSION }}.x-latest} environment: << : *default-environment + LANDO_DROP_USER: root # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep << : *default-volumes-with-external @@ -321,8 +325,8 @@ services: test: << : *lando-common-options - meUser: root services: + user: root build: context: . dockerfile: .docker/Dockerfile.test @@ -341,13 +345,13 @@ services: - cli environment: << : *default-environment + LANDO_DROP_USER: root # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep << : *default-volumes-with-external nginx: << : *lando-common-options - meUser: root # Expose Nginx via lando proxy, note that 'ports' must also be present in # 'services'. moreHttpPorts: @@ -356,6 +360,7 @@ services: # installed yet and Lando DNS might not be setup either. scanner: false services: + user: root build: context: . dockerfile: .docker/Dockerfile.nginx-drupal @@ -375,6 +380,7 @@ services: environment: << : *default-environment LAGOON_LOCALDEV_URL: *default-url + LANDO_DROP_USER: root networks: - amazeeio-network - default @@ -387,8 +393,8 @@ services: php: << : *lando-common-options - meUser: root services: + user: root build: context: . dockerfile: .docker/Dockerfile.php @@ -408,13 +414,13 @@ services: - cli environment: << : *default-environment + LANDO_DROP_USER: root command: /sbin/tini -- /lagoon/entrypoints.sh /usr/local/sbin/php-fpm -F -R << : *default-volumes-with-external mariadb: << : *lando-common-options << : *lando-extra-build-steps - meUser: mysql # Mount the app folder, for db import, db-export. app_mount: true services: @@ -442,7 +448,6 @@ services: command: mysql -uroot --silent --execute "SHOW DATABASES;" av: << : *lando-common-options - meUser: root services: image: govcms/av:latest labels: @@ -454,7 +459,6 @@ services: # Uncomment to enable solr and `proxy` => `solr`. # solr: # << : *lando-common-options - # meUser: solr # # Expose SOLR via lando proxy. # moreHttpPorts: # - '8983' @@ -462,6 +466,7 @@ services: # # installed yet and Lando DNS might be setup either. # scanner: false # services: + # user: solr # build: # context: . # dockerfile: .docker/Dockerfile.solr @@ -477,12 +482,13 @@ services: # - cli # environment: # << : *default-environment + # LANDO_DROP_USER: solr # command: /sbin/tini -- /lagoon/entrypoints.sh solr-foreground chrome: << : *lando-common-options - meUser: seluser services: + user: seluser image: selenium/standalone-chrome:4.5.2-20221021 platform: linux/amd64 shm_size: '1gb' @@ -490,6 +496,8 @@ services: - test labels: lagoon.type: none + environment: + LANDO_DROP_USER: seluser command: /opt/bin/entry_point.sh << : *default-volumes-with-external From 53176899a828223dfec55aefeb990cd0d1a62cf1 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Thu, 16 Apr 2026 15:18:54 +1000 Subject: [PATCH 28/31] Realign volumes for SaaS/PaaS --- .lando.base.yml | 54 +++++++------------ .../scaffold-existing-project-add-lando.sh | 12 +++++ 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index 6de70ac..50702da 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -112,38 +112,24 @@ proxy: # See GOVCMS_IMAGE_VERSION in "Variables" at https://github.com/govCMS/govCMS/wiki x-govcms-image-version: &govcms-image-version ${GOVCMS_IMAGE_VERSION:-{{ GOVCMS_VERSION }}.x-latest} -x-volumes: +x-volumes-lando-tooling: volumes: - - &volume-drupal-themes ./themes:/app/web/themes/custom:${VOLUME_FLAGS:-delegated} - - &volume-drupal-files ./files:/app/web/sites/default/files:delegated - - &volume-behat-features ./tests/behat/features:/app/tests/behat/features:${VOLUME_FLAGS:-delegated} - - &volume-behat-screenshots ./tests/behat/screenshots:/app/tests/behat/screenshots:${VOLUME_FLAGS:-delegated} - - &volume-phpunit-tests ./tests/phpunit/tests:/app/tests/phpunit/tests:${VOLUME_FLAGS:-delegated} - - &volume-drupal-config ./config:/app/config - -x-volumes-paas: - volumes: - - &volume-drupal-app .:/app:delegated - -x-volumes-tooling: - volumes: - - &volume-tooling ./.lando/container:/lando-govcms + - &volume-lando-tooling ./.lando/container:/lando-govcms -# YAML Merge key doesn't work with arrays so use anchors instead/ -x-volumes-with-external: &default-volumes-with-external +x-volumes: &default-volumes volumes: - - *volume-drupal-themes - - *volume-drupal-files - - *volume-behat-features - - *volume-behat-screenshots - - *volume-phpunit-tests - - *volume-drupal-config - - *volume-tooling - -x-volumes-paas-with-external: &paas-volumes-with-external + - ./themes:/app/web/themes/custom:${VOLUME_FLAGS:-delegated} + - ./files:/app/web/sites/default/files:delegated + - ./tests/behat/features:/app/tests/behat/features:${VOLUME_FLAGS:-delegated} + - ./tests/behat/screenshots:/app/tests/behat/screenshots:${VOLUME_FLAGS:-delegated} + - ./tests/phpunit/tests:/app/tests/phpunit/tests:${VOLUME_FLAGS:-delegated} + - ./config:/app/config + - *volume-lando-tooling + +x-volumes-paas: &paas-volumes volumes: - - *volume-drupal-app - - *volume-tooling + - .:/app:delegated + - *volume-lando-tooling # Entry point process isn't PID 1 as lando entrypoint is instead, # so force it to run. @@ -317,7 +303,7 @@ services: LANDO_DROP_USER: root # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep - << : *default-volumes-with-external + << : *default-volumes # Mount volumes from Pygmy to inject host SSH key into container. # https://pygmy.readthedocs.io/en/master/ssh_agent/ volumes_from: @@ -348,7 +334,7 @@ services: LANDO_DROP_USER: root # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep - << : *default-volumes-with-external + << : *default-volumes nginx: << : *lando-common-options @@ -389,7 +375,7 @@ services: # Required for lando proxy 'moreHttpPorts'. ports: - '8080' - << : *default-volumes-with-external + << : *default-volumes php: << : *lando-common-options @@ -416,7 +402,7 @@ services: << : *default-environment LANDO_DROP_USER: root command: /sbin/tini -- /lagoon/entrypoints.sh /usr/local/sbin/php-fpm -F -R - << : *default-volumes-with-external + << : *default-volumes mariadb: << : *lando-common-options @@ -439,7 +425,7 @@ services: # Keep database across lando rebuilds by using named volumes. (1 of 2) - data_mariadb_blank:/var/lib/mysql - data_mariadb_govcms_image:/var/lib/db-data - - *volume-tooling + - *volume-lando-tooling # Keep database across lando rebuilds by using named volumes. (2 of 2) volumes: data_mariadb_blank: @@ -499,7 +485,7 @@ services: environment: LANDO_DROP_USER: seluser command: /opt/bin/entry_point.sh - << : *default-volumes-with-external + << : *default-volumes ########################### ## Drush / ahoy commands ## diff --git a/scripts/scaffold-existing-project-add-lando.sh b/scripts/scaffold-existing-project-add-lando.sh index 284c79b..d927c22 100755 --- a/scripts/scaffold-existing-project-add-lando.sh +++ b/scripts/scaffold-existing-project-add-lando.sh @@ -12,6 +12,7 @@ NC='\033[0m' # No Color ################## TODO "my-project" is "my" instead? GOVCMS_NAME=$(grep -oP 'http:\/\/\K[^\n]+(?=\.docker\.amazee\.io)' docker-compose.yml | head -n 1) GOVCMS_VERSION=$(grep -oP 'GOVCMS_IMAGE_VERSION:-\K\w+' docker-compose.yml | head -n 1) +GOVCMS_TYPE=$(grep -oP '^type:\s+\K\w+' .version.yml | head -n 1) grep -q '^ solr:$' docker-compose.yml HAS_SOLR=$? @@ -25,6 +26,11 @@ if [[ -z "$GOVCMS_VERSION" ]]; then exit 2 fi +if [[ -z "$GOVCMS_TYPE" ]]; then + echo "[error]: Cannot determine scaffold type, must be (saas, saasplus or paas)." + exit 2 +fi + echo "[info]: Modifying scaffold for GovCMS$GOVCMS_VERSION: $GOVCMS_NAME" sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" .lando.base.yml && rm .lando.base.yml.bak @@ -32,6 +38,12 @@ sed -i.bak "s/{{ GOVCMS_PROJECT_NAME }}/$GOVCMS_NAME/" .lando.local.example.yml sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .lando.base.yml && rm .lando.base.yml.bak sed -i.bak "s/{{ GOVCMS_VERSION }}/$GOVCMS_VERSION/" .lando.local.example.yml && rm .lando.local.example.yml.bak +if [[ "$GOVCMS_TYPE" != "paas" ]]; then + : # Do nothing. +else + sed -i.bak -E 's/(\*default-volumes)([[:space:]]|$|#)/\*paas-volumes\2/' .lando.base.yml && rm .lando.base.yml.bak +fi + if [[ "$HAS_SOLR" -eq 0 ]]; then printf "\n${YELLOW}[!! action required !!]${NC}: SOLR has been detected,\n" printf "please uncomment the lando SOLR proxy and service in lando.base.yml\n" From 478cd743e93457b6fe8598f0fd90e4b56d911946 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Thu, 16 Apr 2026 17:05:02 +1000 Subject: [PATCH 29/31] user swucth again without changing the user for av or chrome. --- .lando.base.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index 50702da..6be0766 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -283,6 +283,7 @@ services: cli: << : *lando-common-options << : *lando-extra-build-steps + meUser: root services: user: root build: @@ -300,7 +301,6 @@ services: lagoon.base.image: govcms/govcms:${GOVCMS_IMAGE_VERSION:-{{ GOVCMS_VERSION }}.x-latest} environment: << : *default-environment - LANDO_DROP_USER: root # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep << : *default-volumes @@ -311,6 +311,7 @@ services: test: << : *lando-common-options + meUser: root services: user: root build: @@ -331,13 +332,13 @@ services: - cli environment: << : *default-environment - LANDO_DROP_USER: root # Set Dockerfile entrypoint & CMD togther so lando uses it's secret sauce. command: /sbin/tini -- /lagoon/entrypoints.sh /bin/docker-sleep << : *default-volumes nginx: << : *lando-common-options + meUser: root # Expose Nginx via lando proxy, note that 'ports' must also be present in # 'services'. moreHttpPorts: @@ -366,7 +367,6 @@ services: environment: << : *default-environment LAGOON_LOCALDEV_URL: *default-url - LANDO_DROP_USER: root networks: - amazeeio-network - default @@ -379,6 +379,7 @@ services: php: << : *lando-common-options + meUser: root services: user: root build: @@ -400,13 +401,13 @@ services: - cli environment: << : *default-environment - LANDO_DROP_USER: root command: /sbin/tini -- /lagoon/entrypoints.sh /usr/local/sbin/php-fpm -F -R << : *default-volumes mariadb: << : *lando-common-options << : *lando-extra-build-steps + meUser: mysql # Mount the app folder, for db import, db-export. app_mount: true services: @@ -445,6 +446,7 @@ services: # Uncomment to enable solr and `proxy` => `solr`. # solr: # << : *lando-common-options + # meUser: root # # Expose SOLR via lando proxy. # moreHttpPorts: # - '8983' @@ -452,7 +454,7 @@ services: # # installed yet and Lando DNS might be setup either. # scanner: false # services: - # user: solr + # user: root # build: # context: . # dockerfile: .docker/Dockerfile.solr @@ -468,7 +470,6 @@ services: # - cli # environment: # << : *default-environment - # LANDO_DROP_USER: solr # command: /sbin/tini -- /lagoon/entrypoints.sh solr-foreground chrome: From 2a0a5d13bac7fbeff53c4c630acda27ca7abdc68 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Thu, 16 Apr 2026 17:26:25 +1000 Subject: [PATCH 30/31] Fix solr running as correct user and 'lando ssh' --- .lando.base.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.lando.base.yml b/.lando.base.yml index 6be0766..862d9ef 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -446,15 +446,21 @@ services: # Uncomment to enable solr and `proxy` => `solr`. # solr: # << : *lando-common-options - # meUser: root + # meUser: solr # # Expose SOLR via lando proxy. # moreHttpPorts: # - '8983' # # Skip Lando checking for service to be healthy, the site might not be # # installed yet and Lando DNS might be setup either. # scanner: false + # # Prevent 'lando ssh' failing because "cd /app" as not mounted. + # run_as_root: + # - | + # echo -e "\e[96m#### ($LANDO_SERVICE_NAME) create /app if not exist. ####\e[0m"; + # mkdir -p /app + # echo -e "\e[96m#### ($LANDO_SERVICE_NAME) create /app if not exist - done. ####\e[0m"; # services: - # user: root + # user: solr # build: # context: . # dockerfile: .docker/Dockerfile.solr From e9676ed308e9a61d64692676f025c116754beee3 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Thu, 16 Apr 2026 17:38:36 +1000 Subject: [PATCH 31/31] Remove trailing whitespace --- .lando.base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lando.base.yml b/.lando.base.yml index 862d9ef..9462b9d 100644 --- a/.lando.base.yml +++ b/.lando.base.yml @@ -194,7 +194,7 @@ x-lando-database-tooling-vars: &lando-database-tooling-vars # the druapl user. LANDO_EXTRA_DB_EXPORT_ARGS: -pdrupal --single-transaction # GovCMS SQL container doesn't allow TCP/IP connections. - LANDO_EXTRA_DB_IMPORT_ARGS: -pdrupal --socket=/run/mysqld/mysqld.sock --disable-ssl + LANDO_EXTRA_DB_IMPORT_ARGS: -pdrupal --socket=/run/mysqld/mysqld.sock --disable-ssl x-lando-tooling-mysql-cmd: &lando-mysql-cli-cmd 'mysql -udrupal -pdrupal -h 127.0.0.1 drupal'