Files
track-LICA/frontend/Dockerfile.prod

21 lines
747 B
Docker
Raw Permalink Normal View History

# ============================================================
# 前端生产 Dockerfile — 多阶段构建Vite 打包 → Nginx 托管
# ============================================================
# --- 阶段 1编译 React ---
FROM node:20-alpine AS builder
WORKDIR /app
# 🚀 构建内存优化:显式放宽 node 堆上限,避免低配服务器 OOM 挂起(卡在 vite build
ENV NODE_OPTIONS="--max-old-space-size=4096"
COPY package.json package-lock.json ./
RUN npm ci --production=false
COPY . .
RUN npx vite build
# --- 阶段 2Nginx 托管静态文件 ---
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]