#!/bin/sh set -eu # Ensure persistent state dirs exist (volume may be empty on first boot). mkdir -p /app/state/uploads # Run emdash init on EVERY boot, before exec'ing the server. It is idempotent: # runMigrations applies only pending migrations (no-op when all are applied) and # init skips re-seeding once collections exist. Under `set -e` a non-zero exit # aborts before `exec "$@"`, so a failed/partial init surfaces as a crash-loop # with logs instead of a silently half-migrated boot. (Gating on the mere # presence of data.db would skip pending migrations on image upgrades against an # existing PVC and never recover a partial first-run init.) echo "[entrypoint] running emdash init (applies pending migrations, skips re-seed when collections exist)" node_modules/.bin/emdash init exec "$@"