Files
magikarp-collection/Dockerfile
2025-08-17 13:34:08 +01:00

42 lines
1.0 KiB
Docker

# Multi-stage Dockerfile for Next.js (standalone output)
# 1) Install dependencies
FROM node:20-alpine AS deps
WORKDIR /app
# Install libc6-compat for some native deps if needed
RUN apk add --no-cache libc6-compat
COPY package*.json ./
RUN npm ci
# 2) Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
# 3) Runtime (slim)
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Default internal port Next.js server listens to
ENV PORT=3000
# Copy standalone build output
# This copies the compiled server and minimal node_modules
COPY --from=builder /app/.next/standalone ./
# Static assets
COPY --from=builder /app/.next/static ./.next/static
# Public assets
COPY --from=builder /app/public ./public
# Ensure data directory exists for caching JSON (mounted as a volume in compose)
RUN mkdir -p /app/data
EXPOSE 3000
# Start the standalone server produced by Next.js
CMD ["node", "server.js"]