diff --git a/docker-compose.yml b/docker-compose.yml index ae32d94..318e9b4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,10 +11,10 @@ services: DB_USER: drupal DB_PASS: drupal SITE_NAME: "Riverside Therapeutics" - ADMIN_PASS: "${ADMIN_PASS:-admin}" - HASH_SALT: "${HASH_SALT:-replace-this-in-production-with-a-long-random-string}" + ADMIN_PASS: "${ADMIN_PASS:?ADMIN_PASS is required}" + HASH_SALT: "${HASH_SALT:?HASH_SALT is required}" DEBUG: "${DEBUG:-true}" - POSTMARK_API_KEY: "${POSTMARK_API_KEY:-}" + POSTMARK_API_KEY: "${POSTMARK_API_KEY:?POSTMARK_API_KEY is required}" BASE_URL: "${BASE_URL:-http://localhost:8080}" volumes: - ./web/sites/default/files:/var/www/html/web/sites/default/files diff --git a/docker/php/entrypoint.sh b/docker/php/entrypoint.sh index 484c1bf..dee2564 100644 --- a/docker/php/entrypoint.sh +++ b/docker/php/entrypoint.sh @@ -4,6 +4,14 @@ DB_HOST="${DB_HOST:-postgres}" DB_USER="${DB_USER:-drupal}" DB_NAME="${DB_NAME:-drupal}" +for var in SITE_NAME ADMIN_PASS; do + eval val=\$$var + if [ -z "$val" ]; then + echo "[entrypoint] FATAL: $var is required." + exit 1 + fi +done + echo "[entrypoint] Waiting for PostgreSQL at ${DB_HOST}..." until pg_isready -h "$DB_HOST" -U "$DB_USER" -d "$DB_NAME" -q; do sleep 1 @@ -18,34 +26,25 @@ HAS_TABLES=$($DRUSH sql:query \ "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='public' AND table_name='users';" \ 2>/dev/null || echo "0") -IS_SETUP=$($DRUSH sql:query \ - "SELECT COUNT(*) FROM config WHERE name='core.extension' AND data LIKE '%riverside_pt%';" \ - 2>/dev/null || echo "0") - if [ "$HAS_TABLES" != "1" ]; then echo "[entrypoint] Fresh database, installing Drupal..." $DRUSH site:install standard \ - --site-name="${SITE_NAME:-Portfolio}" \ + --site-name="$SITE_NAME" \ --account-name=admin \ - --account-pass="${ADMIN_PASS:-admin}" \ + --account-pass="$ADMIN_PASS" \ -y || { echo "[entrypoint] FATAL: site:install failed."; exit 1; } echo "[entrypoint] Drupal installed." fi -if [ "$IS_SETUP" != "1" ]; then - echo "[entrypoint] Running first-time setup..." - - $DRUSH en -y views views_ui field_ui text options link datetime && \ - echo "[entrypoint] Core modules enabled." || echo "[entrypoint] WARNING: core modules failed." - $DRUSH en -y webform webform_ui && \ - echo "[entrypoint] Webform enabled." || echo "[entrypoint] WARNING: webform failed." - $DRUSH en -y symfony_mailer && \ - echo "[entrypoint] Mailer enabled." || echo "[entrypoint] WARNING: symfony_mailer failed." - $DRUSH en -y riverside_pt && \ - echo "[entrypoint] riverside_pt enabled." || echo "[entrypoint] WARNING: riverside_pt failed." - - echo "[entrypoint] First-time setup complete." -fi +echo "[entrypoint] Enabling required modules..." +$DRUSH en -y views views_ui field_ui text options link datetime && \ + echo "[entrypoint] Core modules enabled." || echo "[entrypoint] WARNING: core modules failed." +$DRUSH en -y webform webform_ui && \ + echo "[entrypoint] Webform enabled." || echo "[entrypoint] WARNING: webform failed." +$DRUSH en -y symfony_mailer && \ + echo "[entrypoint] Mailer enabled." || echo "[entrypoint] WARNING: symfony_mailer failed." +$DRUSH en -y riverside_pt && \ + echo "[entrypoint] riverside_pt enabled." || echo "[entrypoint] WARNING: riverside_pt failed." $DRUSH theme:enable starterkit_theme claro_compact -y && \ $DRUSH config:set system.theme default starterkit_theme -y && \