Files
vibn-frontend/Dockerfile
Mark Henderson 65ea7ac180 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>
2026-02-17 15:36:44 -08:00

63 lines
1.6 KiB
Docker

# ==================================================
# VIBN Frontend - Next.js on Coolify
# ==================================================
FROM node:22-alpine AS base
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat python3 make g++
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies (with legacy peer deps for compatibility)
RUN npm ci --legacy-peer-deps
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Set environment variables for build
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
# 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
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy built application
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
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Start the application
CMD ["node", "server.js"]