Archived
28 lines
674 B
Bash
28 lines
674 B
Bash
#!/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
|
|
|
|
exec node server.js
|