-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (28 loc) · 1.6 KB
/
Dockerfile
File metadata and controls
39 lines (28 loc) · 1.6 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
# ──────────────────────────────────────────────────────────────────
# Stage 1 — Builder
# Installs dependencies and runs `next build` (static export → out/)
# ──────────────────────────────────────────────────────────────────
FROM node:20-alpine AS builder
WORKDIR /app
# Copy dependency manifests first (layer cache)
COPY package.json package-lock.json* ./
# Install all deps (including devDeps needed for build)
RUN npm ci --frozen-lockfile
# Copy source
COPY . .
# Build — outputs static files to /app/out
RUN npm run build
# ──────────────────────────────────────────────────────────────────
# Stage 2 — Production server
# Lightweight Nginx Alpine image serving the static export
# ──────────────────────────────────────────────────────────────────
FROM nginx:1.27-alpine AS runner
# Remove default nginx page
RUN rm -rf /usr/share/nginx/html/*
# Copy built static files from builder
COPY --from=builder /app/out /usr/share/nginx/html
# Copy custom nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
# Nginx runs in foreground
CMD ["nginx", "-g", "daemon off;"]