From d7eb8b23f75d2b5fd3b9ab0ee3fa158d76e0ed68 Mon Sep 17 00:00:00 2001 From: Greg Date: Sat, 9 Aug 2025 21:33:33 +0000 Subject: [PATCH] Add Dockerfile --- Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d846c5d --- /dev/null +++ b/Dockerfile @@ -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"]