#!/bin/sh set -e # PocketBase data lives on the mounted volume (compose maps ./pb_data → /app/pb_data). PB_DATA=/app/pb_data # Seed a platform superuser from env (idempotent — no-op if it already exists). # If PB_EMAIL/PB_PASSWORD aren't set, skip and rely on manual web setup. if [ -n "$PB_EMAIL" ] && [ -n "$PB_PASSWORD" ]; then echo "[entrypoint] Ensuring PocketBase superuser..." pocketbase superuser upsert "$PB_EMAIL" "$PB_PASSWORD" --dir="$PB_DATA" || true fi # Start PocketBase (internal only; published via loopback for admin UI). # --automigrate=false: we own schema via proxy migrate.ts; PB's built-in # automigrate generates conflicting snapshots on upgraded stores. pocketbase serve --http=0.0.0.0:8090 --dir="$PB_DATA" --automigrate=false & # Wait for PB to be healthy before starting the app (which runs the schema # migration on boot). echo "[entrypoint] Waiting for PocketBase..." for i in $(seq 1 30); do if curl -sf http://127.0.0.1:8090/api/health >/dev/null 2>&1; then echo "[entrypoint] PocketBase is healthy." break fi sleep 1 done # Start the app (SvelteKit + adapter-node). It auto-runs the schema migration. # PORT defaults to 3000 (adapter-node); nginx proxies to it. node /app/frontend/index.js & nginx -g 'daemon off;'