#!/bin/sh set -e run_with_retry() { name="$1" shift attempts="${DOCKER_STARTUP_RETRIES:-30}" delay="${DOCKER_STARTUP_RETRY_DELAY:-2}" current=1 until "$@"; do if [ "$current" -ge "$attempts" ]; then echo "Docker startup step failed after ${attempts} attempts: ${name}" >&2 return 1 fi echo "Docker startup step not ready (${current}/${attempts}): ${name}. Retrying in ${delay}s..." >&2 current=$((current + 1)) sleep "$delay" done } if [ "${RUN_DB_MIGRATIONS:-true}" = "true" ]; then run_with_retry "prisma migrate deploy" npx prisma migrate deploy --schema server/prisma/schema.prisma fi if [ "${RUN_DB_SEED:-true}" = "true" ]; then run_with_retry "prisma db seed" npm run prisma:seed fi exec node server/dist/main.js