Add Dockerfile
This commit is contained in:
parent
9ab261b5de
commit
d7eb8b23f7
38
Dockerfile
Normal file
38
Dockerfile
Normal 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"]
|
||||||
Loading…
x
Reference in New Issue
Block a user