#!/bin/sh # MapleBrief entrypoint # 1) First boot: seed /data with the clean migrated DB + write privileged key if provided # 2) Start Next standalone server set -e cd /app DB="${DATABASE_URL#file:}" [ -n "$DB" ] || DB=/data/dev.db # Export an absolute DATABASE_URL for the Node/Prisma process (relative # paths resolve against the schema dir and can point at the wrong file). case "$DB" in /*) ;; *) DB="/$DB" ;; esac export DATABASE_URL="file:$DB" if [ ! -f "$DB" ]; then # create parent dir (volume may be fresh) DIR="$(dirname "$DB")" mkdir -p "$DIR" cp ./seed-dev.db "$DB" echo "[entrypoint] initialized $DB from seed snapshot" fi # Arm the ingest/synthesis worker once the server answers. # The Next standalone build has instrumentationHook disabled, so node-cron # only starts when a request reaches /api/worker/ping. Pinging ourselves # after boot means a fresh container or restart re-arms the worker (and # triggers the boot pipeline pass) without any external health pinger. ( APP_IP="$(hostname -i 2>/dev/null | awk '{print $1}')" [ -z "$APP_IP" ] && APP_IP=127.0.0.1 i=0 until curl -sf -o /dev/null --max-time 2 "http://${APP_IP}:${PORT:-3000}/api/worker/ping"; do i=$((i + 1)) [ "$i" -ge 90 ] && exit 0 sleep 1 done echo "[entrypoint] armed cron worker via /api/worker/ping" ) >/dev/null 2>&1 & exec node server.js