Skip to content

Commit cdb18f7

Browse files
junzero741claude
andcommitted
fix(docker): compile prisma.config.ts to JS for production runtime
Production stage has no ts-node, so compile the config during build. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1e096fe commit cdb18f7

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

apps/backend/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ RUN pnpm nx build backend
2626
# Prune lockfile + copy workspace modules for production install
2727
RUN pnpm nx prune backend
2828

29+
# Compile prisma.config.ts to JS for production (no ts-node needed)
30+
RUN npx tsc apps/backend/prisma.config.ts --module commonjs --esModuleInterop --outDir /tmp/prisma-config
31+
2932
# --- Production stage ---
3033
FROM node:20-slim
3134

@@ -41,9 +44,9 @@ COPY --from=builder /app/dist/apps/backend ./
4144
# Install production dependencies only
4245
RUN pnpm install --prod --frozen-lockfile
4346

44-
# Copy Prisma schema + config for runtime migrate
47+
# Copy Prisma schema + compiled config for runtime migrate
4548
COPY --from=builder /app/apps/backend/prisma ./prisma
46-
COPY --from=builder /app/apps/backend/prisma.config.ts ./
49+
COPY --from=builder /tmp/prisma-config/apps/backend/prisma.config.js ./
4750

4851
EXPOSE 4000
4952

railway.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
dockerfilePath = "apps/backend/Dockerfile"
33

44
[deploy]
5-
startCommand = "echo '--- migrate ---' && npx prisma migrate deploy && echo '--- starting node ---' && ls main.js && node main.js"
5+
startCommand = "npx prisma migrate deploy --schema=prisma/schema.prisma && node main.js"
66
restartPolicyType = "ON_FAILURE"

0 commit comments

Comments
 (0)