-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
43 lines (32 loc) · 1.72 KB
/
dockerfile
File metadata and controls
43 lines (32 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# ──────────────────────────────────────────────────────────────
# 1. build stage ─ installs exact lockfile versions
# ──────────────────────────────────────────────────────────────
FROM node:22-alpine AS builder
# Re-create the app directory inside the container
WORKDIR /app
# Copy only the package manifests first (layer cache!)
COPY package*.json ./
# Deterministic install that ALSO ignores peer-dep conflicts
# If you later clean up the graph, just drop "--legacy-peer-deps"
RUN npm install --legacy-peer-deps
# Copy the rest of your source code
COPY . .
# Build the production bundle
RUN npm run build
# ──────────────────────────────────────────────────────────────
# 2. runtime stage ─ minimal image that runs Next.js
# ──────────────────────────────────────────────────────────────
FROM node:22-alpine AS runtime
# Create non-root user for security (optional but recommended)
RUN addgroup -S app && adduser -S app -G app
USER app
WORKDIR /app
# Copy only what’s needed to run
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
ENV NODE_ENV=production
EXPOSE 8080
# The container runs `next start`
CMD ["npm", "start"]