From 4e48275054262cb1a400c5f0ac38a040a9475bff Mon Sep 17 00:00:00 2001 From: adonis Date: Sat, 8 Aug 2026 15:49:42 +0330 Subject: [PATCH] Use local Prisma binary in entrypoint to avoid npx network hang. npx can stall checking the registry on restricted networks; migrate never finished so the API never started. Co-authored-by: Cursor --- docker-entrypoint.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index da5a4ec..835495a 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -3,10 +3,22 @@ set -e echo "Node: $(node -v)" echo "OpenSSL: $(openssl version 2>/dev/null || echo missing)" -echo "Waiting for database & applying migrations..." +# فقط host را لاگ کن تا سکرت لو نرود +DB_HOST=$(printf '%s' "$DATABASE_URL" | sed -n 's|.*@\([^:/]*\).*|\1|p') +echo "DATABASE_URL host: ${DB_HOST:-unknown}" + +if [ ! -x ./node_modules/.bin/prisma ]; then + echo "ERROR: ./node_modules/.bin/prisma پیدا نشد. روی سرور npm ci بزن." + exit 1 +fi + +# از npx استفاده نکن — روی بعضی سرورها برای چک رجیستری آویزان می‌ماند +PRISMA="./node_modules/.bin/prisma" + +echo "Waiting for database & applying migrations..." i=0 -until npx prisma migrate deploy; do +until $PRISMA migrate deploy; do i=$((i + 1)) if [ "$i" -ge 30 ]; then echo "Database/migrate failed after 30 attempts" @@ -18,7 +30,7 @@ done if [ "${RUN_SEED:-false}" = "true" ]; then echo "Seeding database..." - npx prisma db seed || true + $PRISMA db seed || true fi echo "Starting API on port ${PORT:-3000}..."