feat: add Docker deployment — multi-stage build + nginx SPA serving

This commit is contained in:
kevin-asprec
2026-03-17 04:13:40 +08:00
parent 5376d1b1d5
commit 2340ae58c6
4 changed files with 66 additions and 0 deletions

25
Dockerfile Normal file
View File

@@ -0,0 +1,25 @@
# ── Stage 1: Build ───────────────────────────────────────
FROM node:22-alpine AS builder
WORKDIR /app
# Install dependencies first (layer cache)
COPY package.json package-lock.json ./
RUN npm ci
# Copy source and build
COPY . .
RUN npm run build
# ── Stage 2: Serve ───────────────────────────────────────
FROM nginx:alpine AS runner
# Copy built assets from builder
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy custom nginx config for SPA routing
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]