43 lines
1.1 KiB
Docker
43 lines
1.1 KiB
Docker
# ---- Stage 1: Dependencies ----
|
|
FROM node:20-alpine AS deps
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci
|
|
|
|
# ---- Stage 2: Build ----
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Generate Prisma Client (uses prisma.config.ts which is in the build context)
|
|
RUN npx prisma generate
|
|
|
|
# Build Next.js
|
|
RUN npm run build
|
|
|
|
# ---- Stage 3: Production ----
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
# Copy built app & dependencies
|
|
COPY --from=builder /app/.next ./.next
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/package.json ./package.json
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
|
COPY --from=builder /app/next.config.mjs ./next.config.mjs
|
|
|
|
# Entrypoint script for migrations + seeding + start
|
|
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
|
|
RUN chmod +x /app/docker-entrypoint.sh
|
|
|
|
EXPOSE 3000
|
|
|
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|