#!/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). pocketbase serve --http=0.0.0.0:8090 --dir="$PB_DATA" & # Wait for PB to be healthy before starting the proxy (which runs migrate). 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 (frontend + proxy). The proxy auto-runs schema migration. # FRONTEND_PORT/PROXY_PORT are set via ENV in the Dockerfile; adapter-node # reads PORT, the proxy reads PROXY_PORT. node /app/frontend/build/index.js & node /app/proxy/dist/index.js & nginx -g 'daemon off;'