19 lines
588 B
Docker
19 lines
588 B
Docker
# ============================================================
|
||
# 前端生产 Dockerfile — 多阶段构建:Vite 打包 → Nginx 托管
|
||
# ============================================================
|
||
|
||
# --- 阶段 1:编译 React ---
|
||
FROM node:20-alpine AS builder
|
||
WORKDIR /app
|
||
COPY package.json package-lock.json ./
|
||
RUN npm ci --production=false
|
||
COPY . .
|
||
RUN npx vite build
|
||
|
||
# --- 阶段 2:Nginx 托管静态文件 ---
|
||
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;"]
|