Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .docker/cli.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 \
SIMPLETEST_BASE_URL=http://nginx:8080 \
SYMFONY_DEPRECATIONS_HELPER=disabled

# Allow custom PHP runtime configuration for Drush CLI commands.
# The leading colon appends to the default scan directories.
# @see https://github.com/drevops/vortex/issues/1913
ENV PHP_INI_SCAN_DIR="${PHP_INI_SCAN_DIR}:/app/drush/php-ini"

# Starting from this line, Docker adds the result of each command as a
# separate layer. These layers are cached and reused when the project is
# rebuilt. Layers are only rebuilt if the files added with `ADD` have changed
Expand Down
27 changes: 27 additions & 0 deletions .vortex/docs/content/tools/drush.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,33 @@ import TabItem from '@theme/TabItem';
</TabItem>
</Tabs>

## PHP runtime configuration

Vortex allows you to customize PHP runtime settings for Drush CLI 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.

For example, to increase the memory limit for Drush operations:

```ini
; drush/php-ini/drush.ini
memory_limit = 512M
```

Any valid PHP ini directive can be added to this file to adjust the runtime
behavior of Drush commands.

:::note

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.

:::

## Aliases

For Lagoon hosting, Drush site aliases are automatically generated for each
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 \
SIMPLETEST_BASE_URL=http://nginx:8080 \
SYMFONY_DEPRECATIONS_HELPER=disabled

# Allow custom PHP runtime configuration for Drush CLI commands.
# The leading colon appends to the default scan directories.
# @see https://github.com/drevops/vortex/issues/1913
ENV PHP_INI_SCAN_DIR="${PHP_INI_SCAN_DIR}:/app/drush/php-ini"

# Starting from this line, Docker adds the result of each command as a
# separate layer. These layers are cached and reused when the project is
# rebuilt. Layers are only rebuilt if the files added with `ADD` have changed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
; Custom PHP runtime configuration for Drush CLI commands.
;
; This file is auto-discovered via the PHP_INI_SCAN_DIR environment variable.
; Modify the values below to adjust PHP runtime settings for Drush commands.
;
; @see https://github.com/drevops/vortex/issues/1913

; Increase memory limit for Drush operations (database imports, config sync).
memory_limit = 512M
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ target_env="${2}"

pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1

# Allow custom PHP runtime configuration for Drush CLI commands.
# The leading colon appends to the default scan directories.
# @see https://github.com/drevops/vortex/issues/1913
PHP_INI_SCAN_DIR="${PHP_INI_SCAN_DIR:-}:$(pwd)/drush/php-ini"
export PHP_INI_SCAN_DIR

# Do not unblock admin account.
export VORTEX_UNBLOCK_ADMIN="${VORTEX_UNBLOCK_ADMIN:-0}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ target_env="${2}"

pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1

# Allow custom PHP runtime configuration for Drush CLI commands.
# The leading colon appends to the default scan directories.
# @see https://github.com/drevops/vortex/issues/1913
PHP_INI_SCAN_DIR="${PHP_INI_SCAN_DIR:-}:$(pwd)/drush/php-ini"
export PHP_INI_SCAN_DIR

# Do not unblock admin account.
export VORTEX_UNBLOCK_ADMIN="${VORTEX_UNBLOCK_ADMIN:-0}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ENV DRUPAL_THEME=${DRUPAL_THEME}

ARG VORTEX_FRONTEND_BUILD_SKIP="0"
@@ -84,12 +84,5 @@
@@ -89,12 +89,5 @@

# Create file directories and set correct permissions.
RUN mkdir -p -m 2775 "/app/${WEBROOT}/${DRUPAL_PUBLIC_FILES}" "/app/${WEBROOT}/${DRUPAL_PRIVATE_FILES}" "${DRUPAL_TEMPORARY_FILES}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ENV DRUPAL_THEME=${DRUPAL_THEME}

ARG VORTEX_FRONTEND_BUILD_SKIP="0"
@@ -84,12 +84,5 @@
@@ -89,12 +89,5 @@

# Create file directories and set correct permissions.
RUN mkdir -p -m 2775 "/app/${WEBROOT}/${DRUPAL_PUBLIC_FILES}" "/app/${WEBROOT}/${DRUPAL_PRIVATE_FILES}" "${DRUPAL_TEMPORARY_FILES}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ENV DRUPAL_THEME=${DRUPAL_THEME}

ARG VORTEX_FRONTEND_BUILD_SKIP="0"
@@ -84,12 +84,5 @@
@@ -89,12 +89,5 @@

# Create file directories and set correct permissions.
RUN mkdir -p -m 2775 "/app/${WEBROOT}/${DRUPAL_PUBLIC_FILES}" "/app/${WEBROOT}/${DRUPAL_PRIVATE_FILES}" "${DRUPAL_TEMPORARY_FILES}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function testDockerComposeWorkflowFull(): void {

$this->subtestDockerComposeTimezone();

$this->subtestDockerComposeDrushPhpIni();

$this->subtestSolr();

$this->logSubstep('Installing development dependencies');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,51 @@ protected function subtestDockerComposeTimezone(): void {
$this->logStepFinish();
}

protected function subtestDockerComposeDrushPhpIni(): void {
$this->logStepStart();

$ini_file = 'drush/php-ini/drush.ini';

$this->logSubstep('Assert default PHP ini values from drush.ini are applied.');
$this->assertFileExists($ini_file, 'Drush PHP ini file should exist');
$this->assertFileContainsString($ini_file, 'memory_limit = 512M', 'Drush PHP ini file should contain default memory_limit');
$this->cmd(
'docker compose exec -T cli php -r "echo ini_get(\'memory_limit\');"',
'512M',
'PHP memory_limit should be 512M from drush.ini'
);

$this->logSubstep('Assert PHP ini values are updated when drush.ini is changed.');
$this->fileBackup($ini_file);
File::dump($ini_file, "memory_limit = 256M\n");
$this->syncToContainer($ini_file);
$this->cmd(
'docker compose exec -T cli php -r "echo ini_get(\'memory_limit\');"',
'256M',
'PHP memory_limit should be 256M after changing drush.ini'
);

$this->logSubstep('Assert multiple PHP ini directives are applied.');
File::dump($ini_file, "memory_limit = 1024M\nerror_reporting = E_ALL\n");
$this->syncToContainer($ini_file);
$this->cmd(
'docker compose exec -T cli php -r "echo ini_get(\'memory_limit\');"',
'1024M',
'PHP memory_limit should be 1024M after second change'
);
$this->cmd(
'docker compose exec -T cli php -r "echo ini_get(\'error_reporting\');"',
'32767',
'PHP error_reporting should be 32767 (E_ALL) from drush.ini'
);

$this->logSubstep('Restore drush.ini to original state.');
$this->fileRestore($ini_file);
$this->syncToContainer($ini_file);

$this->logStepFinish();
}
Comment on lines +278 to +321
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Ensure drush.ini is always restored (even on assertion failures).
A failing assertion before restore will leave the file modified and can cascade into later tests.

✅ Suggested fix (try/finally restore)
-    $this->logSubstep('Assert PHP ini values are updated when drush.ini is changed.');
-    $this->fileBackup($ini_file);
-    File::dump($ini_file, "memory_limit = 256M\n");
-    $this->syncToContainer($ini_file);
-    $this->cmd(
-      'docker compose exec -T cli php -r "echo ini_get(\'memory_limit\');"',
-      '256M',
-      'PHP memory_limit should be 256M after changing drush.ini'
-    );
-
-    $this->logSubstep('Assert multiple PHP ini directives are applied.');
-    File::dump($ini_file, "memory_limit = 1024M\nerror_reporting = E_ALL\n");
-    $this->syncToContainer($ini_file);
-    $this->cmd(
-      'docker compose exec -T cli php -r "echo ini_get(\'memory_limit\');"',
-      '1024M',
-      'PHP memory_limit should be 1024M after second change'
-    );
-    $this->cmd(
-      'docker compose exec -T cli php -r "echo ini_get(\'error_reporting\');"',
-      '32767',
-      'PHP error_reporting should be 32767 (E_ALL) from drush.ini'
-    );
-
-    $this->logSubstep('Restore drush.ini to original state.');
-    $this->fileRestore($ini_file);
-    $this->syncToContainer($ini_file);
-
-    $this->logStepFinish();
+    $this->fileBackup($ini_file);
+    try {
+      $this->logSubstep('Assert PHP ini values are updated when drush.ini is changed.');
+      File::dump($ini_file, "memory_limit = 256M\n");
+      $this->syncToContainer($ini_file);
+      $this->cmd(
+        'docker compose exec -T cli php -r "echo ini_get(\'memory_limit\');"',
+        '256M',
+        'PHP memory_limit should be 256M after changing drush.ini'
+      );
+
+      $this->logSubstep('Assert multiple PHP ini directives are applied.');
+      File::dump($ini_file, "memory_limit = 1024M\nerror_reporting = E_ALL\n");
+      $this->syncToContainer($ini_file);
+      $this->cmd(
+        'docker compose exec -T cli php -r "echo ini_get(\'memory_limit\');"',
+        '1024M',
+        'PHP memory_limit should be 1024M after second change'
+      );
+      $this->cmd(
+        'docker compose exec -T cli php -r "echo ini_get(\'error_reporting\');"',
+        '32767',
+        'PHP error_reporting should be 32767 (E_ALL) from drush.ini'
+      );
+    }
+    finally {
+      $this->logSubstep('Restore drush.ini to original state.');
+      $this->fileRestore($ini_file);
+      $this->syncToContainer($ini_file);
+      $this->logStepFinish();
+    }
🤖 Prompt for AI Agents
In @.vortex/tests/phpunit/Traits/Subtests/SubtestDockerComposeTrait.php around
lines 278 - 321, Wrap the parts of subtestDockerComposeDrushPhpIni that modify
drush/php-ini/drush.ini and run assertions in a try/finally so the original file
is always restored: call fileBackup($ini_file) before modifications, then in a
finally block call fileRestore($ini_file) and syncToContainer($ini_file) to
ensure restoration and container sync even if an assertion (or any exception)
fails; keep existing cmd/assert checks inside the try and ensure the final
logStepFinish() remains after restoration.


protected function subtestSolr(): void {
$this->logStepStart();

Expand Down
9 changes: 9 additions & 0 deletions drush/php-ini/drush.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
; Custom PHP runtime configuration for Drush CLI commands.
;
; This file is auto-discovered via the PHP_INI_SCAN_DIR environment variable.
; Modify the values below to adjust PHP runtime settings for Drush commands.
;
; @see https://github.com/drevops/vortex/issues/1913

; Increase memory limit for Drush operations (database imports, config sync).
memory_limit = 512M
6 changes: 6 additions & 0 deletions hooks/library/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ target_env="${2}"

pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1

# Allow custom PHP runtime configuration for Drush CLI commands.
# The leading colon appends to the default scan directories.
# @see https://github.com/drevops/vortex/issues/1913
PHP_INI_SCAN_DIR="${PHP_INI_SCAN_DIR:-}:$(pwd)/drush/php-ini"
export PHP_INI_SCAN_DIR
Comment on lines +14 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat docs/deployment.md

Repository: drevops/vortex

Length of output: 1704


🏁 Script executed:

cat -n hooks/library/provision.sh

Repository: drevops/vortex

Length of output: 848


Ensure PHP_INI_SCAN_DIR preserves default scan directories when already set.

If PHP_INI_SCAN_DIR is already defined in the environment without a leading colon (possible from Acquia), the current assignment concatenates without a leading colon, causing PHP to skip its default configuration directories. Normalize the value to ensure a leading colon is always present before appending.

Suggested fix
-# Allow custom PHP runtime configuration for Drush CLI commands.
-# The leading colon appends to the default scan directories.
-# `@see` https://github.com/drevops/vortex/issues/1913
-PHP_INI_SCAN_DIR="${PHP_INI_SCAN_DIR:-}:$(pwd)/drush/php-ini"
-export PHP_INI_SCAN_DIR
+# Allow custom PHP runtime configuration for Drush CLI commands.
+# The leading colon appends to the default scan directories.
+# `@see` https://github.com/drevops/vortex/issues/1913
+ini_scan_dir="${PHP_INI_SCAN_DIR:-}"
+if [ -n "${ini_scan_dir}" ] && [[ "${ini_scan_dir}" != :* ]]; then
+  ini_scan_dir=":${ini_scan_dir}"
+fi
+PHP_INI_SCAN_DIR="${ini_scan_dir:-:}:$(pwd)/drush/php-ini"
+export PHP_INI_SCAN_DIR
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Allow custom PHP runtime configuration for Drush CLI commands.
# The leading colon appends to the default scan directories.
# @see https://github.com/drevops/vortex/issues/1913
PHP_INI_SCAN_DIR="${PHP_INI_SCAN_DIR:-}:$(pwd)/drush/php-ini"
export PHP_INI_SCAN_DIR
# Allow custom PHP runtime configuration for Drush CLI commands.
# The leading colon appends to the default scan directories.
# `@see` https://github.com/drevops/vortex/issues/1913
ini_scan_dir="${PHP_INI_SCAN_DIR:-}"
if [ -n "${ini_scan_dir}" ] && [[ "${ini_scan_dir}" != :* ]]; then
ini_scan_dir=":${ini_scan_dir}"
fi
PHP_INI_SCAN_DIR="${ini_scan_dir:-:}:$(pwd)/drush/php-ini"
export PHP_INI_SCAN_DIR
🤖 Prompt for AI Agents
In `@hooks/library/provision.sh` around lines 14 - 18, The PHP_INI_SCAN_DIR
assignment can drop the default scan dirs when the existing value lacks a
leading colon; update the logic in hooks/library/provision.sh around the
PHP_INI_SCAN_DIR assignment so that you normalize the existing PHP_INI_SCAN_DIR
by ensuring it begins with a colon (if non-empty and not already starting with
':') before appending :$(pwd)/drush/php-ini, then export PHP_INI_SCAN_DIR;
reference the PHP_INI_SCAN_DIR variable in your change.


# Do not unblock admin account.
export VORTEX_UNBLOCK_ADMIN="${VORTEX_UNBLOCK_ADMIN:-0}"

Expand Down