Add Dockerfile

This commit is contained in:
Greg 2025-08-09 21:33:33 +00:00
parent 9ab261b5de
commit d7eb8b23f7

38
Dockerfile Normal file
View File

@ -0,0 +1,38 @@
# ---- 1) Install deps (cached) ----------------------------------------------
FROM node:20-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci
# ---- 2) Build the Next.js app ----------------------------------------------
FROM node:20-alpine AS builder
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# ---- 3) Runtime: copy standalone output, run as non-root -------------------
FROM node:20-alpine AS runner
WORKDIR /app
# Environment
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
# Non-root user
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
# Copy only what's needed to run the server
# - .next/standalone includes server.js and minimal node_modules
# - .next/static and public are needed for assets
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# Expose Next.js port
EXPOSE 3000
USER 1001
CMD ["node", "server.js"]