#!/bin/sh set -eu # Ensure persistent state dirs exist (volume may be empty on first boot). mkdir -p /app/state/uploads # Run emdash init + seed on EVERY boot, before exec'ing the server. Both are # idempotent: `init` runs only pending migrations (no-op when all applied) and # `seed` applies seed/seed.json with onConflict=skip (no-op once rows exist). # `init` does NOT load JSON seeds — that moved to the separate `emdash seed` # command — so without this seed step the catalog boots empty. Under `set -e` a # non-zero exit aborts before `exec "$@"`, so a failed/partial init or seed # surfaces as a crash-loop with logs instead of a silently half-set-up 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)" node_modules/.bin/emdash init # Seed is best-effort: unlike migrations, a content-seed failure (e.g. a bad # seed.json entry) must NOT crash-loop the whole site, so it is NOT under the # `set -e` abort. We still surface a non-zero rc loudly in the logs rather than # swallowing it silently. echo "[entrypoint] running emdash seed (applies seed/seed.json, onConflict=skip)" if node_modules/.bin/emdash seed; then echo "[entrypoint] emdash seed ok" else echo "[entrypoint] WARNING: emdash seed failed (rc=$?) — serving without full seed" >&2 fi exec "$@"