-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.frontend
More file actions
32 lines (24 loc) · 1.05 KB
/
Dockerfile.frontend
File metadata and controls
32 lines (24 loc) · 1.05 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
# ============================================================================
# Stage 1 — Build the Vite/React application
# ============================================================================
FROM node:20-alpine AS builder
WORKDIR /app
# Install dependencies first (layer-cached separately from source code)
COPY frontend/package*.json ./
RUN npm ci --frozen-lockfile
# Copy source and build
COPY frontend/ .
RUN npm run build
# Output lands in /app/dist
# ============================================================================
# Stage 2 — Serve the static bundle with nginx
# nginx:alpine is ~25 MB vs ~1.5 GB for node:20.
# Also eliminates the Vite dev-server security surface (source maps, HMR socket).
# ============================================================================
FROM nginx:alpine AS production
# Copy built assets
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy nginx site config (API proxy, SPA routing, gzip)
COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]