customer-riverside/docker/php/entrypoint.sh

58 lines
1.7 KiB
Bash
Raw Normal View History

2026-04-19 20:33:56 -08:00
#!/bin/sh
set -e
DB_HOST="${DB_HOST:-postgres}"
DB_USER="${DB_USER:-drupal}"
DB_NAME="${DB_NAME:-drupal}"
echo "[entrypoint] Waiting for PostgreSQL at ${DB_HOST}..."
until pg_isready -h "$DB_HOST" -U "$DB_USER" -d "$DB_NAME" -q; do
sleep 1
done
echo "[entrypoint] PostgreSQL is ready."
cd /var/www/html
DRUSH="vendor/bin/drush --root=/var/www/html/web"
HAS_TABLES=$($DRUSH sql:query \
"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='public' AND table_name='config';" \
2>/dev/null || echo "0")
if [ "$HAS_TABLES" = "1" ]; then
echo "[entrypoint] Database populated, importing configuration..."
$DRUSH config:import -y 2>/dev/null && \
echo "[entrypoint] Config imported." || \
echo "[entrypoint] No config to import, continuing."
2026-05-12 16:38:52 -08:00
$DRUSH theme:enable claro_compact -y
2026-04-19 20:33:56 -08:00
else
echo "[entrypoint] Fresh database, installing Drupal..."
2026-05-12 16:28:47 -08:00
$DRUSH site:install standard \
2026-04-19 20:33:56 -08:00
--site-name="${SITE_NAME:-Portfolio}" \
--account-name=admin \
--account-pass="${ADMIN_PASS:-admin}" \
-y
echo "[entrypoint] Drupal installed."
2026-05-01 03:18:57 -08:00
echo "[entrypoint] Enabling modules..."
$DRUSH en -y views views_ui field_ui text options link datetime
$DRUSH en -y webform webform_ui
$DRUSH en -y symfony_mailer
2026-05-12 16:28:47 -08:00
2026-05-01 04:34:37 -08:00
$DRUSH en -y riverside_pt
2026-05-01 03:18:57 -08:00
echo "[entrypoint] Modules enabled."
2026-05-12 16:38:52 -08:00
echo "[entrypoint] Setting themes..."
2026-05-12 16:28:47 -08:00
$DRUSH theme:enable olivero claro_compact
2026-05-01 03:42:53 -08:00
echo "[entrypoint] Themes set."
2026-05-01 03:18:57 -08:00
2026-04-19 20:33:56 -08:00
if ls /var/www/html/config/sync/*.yml >/dev/null 2>&1; then
echo "[entrypoint] Importing configuration from sync dir..."
$DRUSH config:import -y
fi
fi
2026-05-01 03:42:53 -08:00
2026-04-19 20:33:56 -08:00
echo "[entrypoint] Starting services..."
exec supervisord -c /etc/supervisor/conf.d/supervisord.conf