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 <cursoragent@cursor.com>
This commit is contained in:
2026-02-17 15:36:44 -08:00
parent bbb22f1c37
commit 65ea7ac180
3 changed files with 17 additions and 2 deletions

View File

@@ -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