fix: ensure FarmOS correctly uses environment variables for DB connection

This commit is contained in:
fchinembiri 2026-05-21 19:15:43 +02:00
parent 6435130215
commit 21dd488a86
1 changed files with 4 additions and 0 deletions

View File

@ -53,6 +53,10 @@ spec:
cpu: "200m"
limits:
memory: "1Gi"
lifecycle:
postStart:
exec:
command: ["sh", "-c", "if [ ! -f /opt/drupal/web/sites/default/settings.local.php ]; then cat <<EOF > /opt/drupal/web/sites/default/settings.local.php\n<?php\n\\$databases['default']['default'] = [\n 'database' => getenv('FARMOS_DB_NAME'),\n 'username' => getenv('FARMOS_DB_USER'),\n 'password' => getenv('FARMOS_DB_PASS'),\n 'prefix' => '',\n 'host' => getenv('FARMOS_DB_HOST'),\n 'port' => getenv('FARMOS_DB_PORT'),\n 'namespace' => 'Drupal\\\\Core\\\\Database\\\\Driver\\\\pgsql',\n 'driver' => 'pgsql',\n];\nEOF\nfi && if ! grep -q \"settings.local.php\" /opt/drupal/web/sites/default/settings.php; then echo \"\nif (file_exists(\\$app_root . '/' . \\$site_path . '/settings.local.php')) {\n include \\$app_root . '/' . \\$site_path . '/settings.local.php';\n}\" >> /opt/drupal/web/sites/default/settings.php; fi"]
volumeMounts:
- name: sites
mountPath: /opt/drupal/web/sites