Drush
Drush is a command line shell and Unix scripting interface for Drupal. Drush core ships with lots of useful commands and generators. Similarly, it runs update.php, executes SQL queries, runs content migrations, and misc utilities like cron or cache rebuild. Drush can be extended by 3rd party commandfiles.
Drush is used throughout Vortex to interact with Drupal from the automation scripts and Behat tests.
It also allows a developer to interact with the site via CLI during development.
While all the standard Drush commands are supported, Vortex also provides shorthand commands that wrap the common tasks:
ahoy fetch-db- fetch the database dump from the remote environmentahoy import-db- import the database dump into the local environmentahoy provision- import the database and run updates, config imports and cache rebuilds
Usage
Drush should be used from the inside of the container.
- Ahoy
- Docker Compose
ahoy drush <command>
docker compose exec cli drush <command>
Configuration
The shipped Drush configuration lives in the drush/ directory:
drush/drush.ymlpasses--disable-sslto thesql:*commands (sql:cli,sql:query,sql:dump,sql:drop,sql:create) andsite:install, so the database commands connect to the stack's database service without TLS, and adds--no-tablespacestosql:dump.drush/sites/lagoon.site.ymldefines the site aliases for Lagoon-hosted environments - see Aliases.drush/php-ini/drush.iniadjusts the PHP runtime for CLI processes - see PHP runtime configuration.
PHP runtime configuration
Vortex allows you to customize PHP runtime settings for PHP CLI processes,
including Drush commands, by editing the drush/php-ini/drush.ini file.
This file is auto-discovered via the PHP_INI_SCAN_DIR environment variable,
which is pre-configured in both the Docker CLI container and Acquia deployment
hooks. Every PHP CLI process that loads this scan path picks the file up, not
only Drush.
Any valid PHP ini directive can be added to this file to adjust the runtime behavior of those processes.
The leading colon in the PHP_INI_SCAN_DIR value preserves the default scan
directories. On Acquia, this ensures that the hosting provider's own PHP ini
overrides (such as sendmail_path) are not lost.
Memory limit
The shipped configuration raises the PHP memory limit above the platform default:
; drush/php-ini/drush.ini
memory_limit = 1G
This value is sized for database imports and configuration synchronization on large sites. It applies to PHP CLI processes that load this scan path, including Drush, and does not change the memory limit used to serve web requests.
If a Drush command exhausts this limit, profile the command before raising the value. An exhausted 1G limit usually points to a memory leak in custom code rather than a limit set too low, and raising the ceiling hides the leak until a larger dataset reaches the new limit.
To grant more memory to a single command without changing the default:
- Ahoy
- Docker Compose
ahoy cli php -d memory_limit=2G vendor/bin/drush <command>
docker compose exec cli php -d memory_limit=2G vendor/bin/drush <command>
Aliases
For Lagoon hosting, the shipped
drush/sites/lagoon.site.yml
file defines a wildcard alias, so every environment resolves as
@lagoon.<branch-or-pr> without per-environment entries. The aliases can be
used either from the host machine or from within the container.
The project name is hardcoded in the alias file because Drush does not load
variables from .env files - this keeps the aliases working identically on
the host and in the container.
- Host
- Ahoy
- Docker Compose
- Make sure your SSH key is loaded in your
ssh-agent:
ssh-add ~/.ssh/path/to/key
- Run Drush commands using the Lagoon site aliases:
drush @lagoon.develop status # Show status of the develop environment
drush @lagoon.pr-123 ssh # SSH into the web container of the PR-123 environment
- Make sure your SSH key is loaded into
pygmy:
pygmy addkey --key ~/.ssh/path/to/key
- Run Drush commands using the Lagoon site aliases:
ahoy drush @lagoon.develop status # Show status of the develop environment
ahoy drush @lagoon.pr-123 ssh # SSH into the web container of the PR-123 environment
- Make sure your SSH key is loaded into
pygmy:
pygmy addkey --key ~/.ssh/path/to/key
- Run Drush commands using the Lagoon site aliases:
docker compose exec cli drush @lagoon.develop status # Show status of the develop environment
docker compose exec cli drush @lagoon.pr-123 ssh # SSH into the web container of the PR-123 environment