Ship prebuilt Prisma client so the server never runs prisma generate

prisma generate needs over three minutes on the production host, which made
every deploy hang on that build step. The client is now generated on the dev
machine into prisma-client.tar.gz (tracked, 8.5MB) and the image just untars
it. Dropping the unused linux-musl engine target halves that payload.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-08 16:35:06 +03:30
co-authored by Cursor
parent aa9b3ee451
commit d5dfd6a0f0
7 changed files with 49 additions and 12 deletions
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# کلاینت Prisma را روی سیستم دولوپر می‌سازد و بسته‌بندی می‌کند.
# سرور نباید prisma generate بزند؛ روی هاست پروडاکشن دقایق طول می‌کشد.
set -euo pipefail
cd "$(dirname "$0")/.."
OUT="prisma-client.tar.gz"
SRC="node_modules/.prisma/client"
if [ ! -d node_modules/prisma ]; then
echo "ERROR: node_modules نیست. اول npm ci بزن." >&2
exit 1
fi
# خروجی قبلی پاک شود تا engineهای بی‌استفاده در بسته نمانند
rm -rf "$SRC"
DATABASE_URL="${DATABASE_URL:-postgresql://build:build@localhost:5432/build?schema=public}" \
CHECKPOINT_DISABLE=1 ./node_modules/.bin/prisma generate
test -f "$SRC/libquery_engine-debian-openssl-3.0.x.so.node" \
|| { echo "ERROR: engine مربوط به debian-openssl-3.0.x ساخته نشد." >&2; exit 1; }
rm -f "$OUT"
tar -czf "$OUT" -C node_modules/.prisma client
ls -lh "$OUT"