From 65ea7ac1809eb85565bd493bb0ef78ba0b38a8b4 Mon Sep 17 00:00:00 2001 From: Mark Henderson Date: Tue, 17 Feb 2026 15:36:44 -0800 Subject: [PATCH] Fix Dockerfile for NextAuth + Prisma deployment Add Prisma support to Docker build: - Run 'prisma generate' during Docker build - Copy Prisma client and schema to production image - Remove 'prisma db push' from build script (runs at startup) - Enable Next.js standalone output mode - Add db-setup.sh script for runtime migrations This fixes the deployment failure where Prisma wasn't available. Co-authored-by: Cursor --- Dockerfile | 10 +++++++++- package.json | 2 +- scripts/db-setup.sh | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100755 scripts/db-setup.sh diff --git a/Dockerfile b/Dockerfile index 15559d7..500569a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,10 @@ COPY . . ENV NEXT_TELEMETRY_DISABLED=1 ENV NODE_ENV=production -# Build the application +# Generate Prisma Client (needs schema but not DATABASE_URL yet) +RUN npx prisma generate + +# Build the application (DATABASE_URL will be available via Coolify env vars) RUN npm run build # Production image, copy all the files and run next @@ -43,6 +46,11 @@ COPY --from=builder /app/public ./public COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +# Copy Prisma files for runtime +COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma +COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma +COPY --from=builder /app/prisma ./prisma + USER nextjs EXPOSE 3000 diff --git a/package.json b/package.json index 0550af6..a279496 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "prisma generate && prisma db push --accept-data-loss && next build", + "build": "next build", "start": "next start", "lint": "eslint", "postinstall": "prisma generate", diff --git a/scripts/db-setup.sh b/scripts/db-setup.sh new file mode 100755 index 0000000..f7e7e8d --- /dev/null +++ b/scripts/db-setup.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Run database migrations at container startup +# This ensures DATABASE_URL is available from Coolify env vars + +echo "Running Prisma DB setup..." +npx prisma db push --accept-data-loss --skip-generate +echo "Database setup complete!"