Files
kleinholz/Dockerfile
T
2026-02-19 03:54:47 +01:00

35 lines
772 B
Docker

# --- Base image ---
FROM node:22-alpine AS base
WORKDIR /app
# --- Install dependencies ---
FROM base AS deps
COPY package.json package-lock.json* ./
RUN npm ci
# --- Build the Next.js app ---
FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# --- Production runtime ---
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Create non-root user
RUN addgroup -g 1001 nodejs \
&& adduser -u 1001 -G nodejs -s /bin/sh -D nextjs
# Copy only what is needed for runtime
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
USER nextjs
EXPOSE 3000
CMD ["npm", "start"]