64 lines
1.5 KiB
Docker
64 lines
1.5 KiB
Docker
# Multi-stage build for Next.js 16 with Webpack + Prisma
|
|
# Using Debian Slim for OpenSSL 3.x compatibility
|
|
|
|
FROM node:22-slim AS base
|
|
|
|
FROM base AS deps
|
|
WORKDIR /app
|
|
|
|
# Install OpenSSL (already 3.x in Debian Slim)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
openssl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install dependencies
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm install --legacy-peer-deps
|
|
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Force Prisma to use OpenSSL 3.x (Debian 12)
|
|
ENV PRISMA_BINARY_TARGETS=native,debian-openssl-3.0.x
|
|
|
|
# Generate Prisma Client with forced binary target
|
|
RUN npx prisma generate
|
|
|
|
# Build Next.js with Webpack
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
RUN npm run build
|
|
|
|
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 --from=builder /app/public ./public
|
|
|
|
RUN mkdir .next
|
|
RUN chown nextjs:nodejs .next
|
|
|
|
# Copy Next.js standalone output
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
# Copy Prisma files - including generated binaries
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.prisma ./node_modules/.prisma
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/@prisma ./node_modules/@prisma
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
CMD ["node", "server.js"]
|