opencrm/backend/docker-entrypoint.sh

28 lines
914 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# Beim Container-Start: Schema in DB pushen (idempotent) + (optional) seed.
# RUN_SEED=true beim ersten Start setzen, danach wieder auf false.
set -e
echo "[entrypoint] Warte auf Datenbank…"
# Prisma versucht selbst Connect; einfacher Retry-Loop um Race-Bedingungen
# beim parallelen Container-Start abzufangen.
TRIES=30
until npx prisma db push --skip-generate --accept-data-loss 2>/dev/null; do
TRIES=$((TRIES - 1))
if [ "$TRIES" -le 0 ]; then
echo "[entrypoint] DB nicht erreichbar Abbruch"
exit 1
fi
echo "[entrypoint] DB noch nicht bereit retry in 2s ($TRIES Versuche übrig)"
sleep 2
done
echo "[entrypoint] DB-Schema synced"
if [ "${RUN_SEED:-false}" = "true" ]; then
echo "[entrypoint] RUN_SEED=true seede DB"
npx prisma db seed || echo "[entrypoint] Seed fehlgeschlagen oder schon gelaufen ignoriert"
fi
echo "[entrypoint] Starte Backend…"
exec "$@"