#!/bin/sh # Container entrypoint for the parking server. Applies DB migrations against the mounted # volume (DATABASE_URL), optionally seeds the first admin, then execs the server. Idempotent: # the runtime migrator (drizzle-orm migrator, no drizzle-kit) only applies pending migrations, # so a restart is a no-op. See packages/db/scripts/migrate-runtime.mjs. set -e echo "[entrypoint] DATABASE_URL=${DATABASE_URL}" # Apply migrations against the mounted DB file (creates it + the schema on first boot). # The migrator ships inside the @parking/db package in the deploy bundle's node_modules. node node_modules/@parking/db/scripts/migrate-runtime.mjs # Optional first-boot admin seed: set SEED_ADMIN=1 plus ADMIN_USER + ADMIN_PASS (the seed # script PROMPTS when these are unset, which would hang a container — so require ADMIN_PASS). # The seed is idempotent: it won't overwrite an existing user unless FORCE=1. if [ "${SEED_ADMIN}" = "1" ]; then if [ -z "${ADMIN_PASS}" ]; then echo "[entrypoint] SEED_ADMIN=1 but ADMIN_PASS is unset — skipping seed (would hang on prompt)" else echo "[entrypoint] seeding admin (${ADMIN_USER:-admin})" node scripts/seed-admin.mjs || echo "[entrypoint] seed-admin skipped/failed (non-fatal)" fi fi echo "[entrypoint] starting server" exec "$@"