# ================================================================ # VetCopilot 前端 Dockerfile(多阶段构建) # # 构建: docker build -f deploy/Dockerfile.frontend -t vetcopilot-frontend . # ================================================================ # ---- Stage 1: 构建 ---- FROM node:22-alpine AS builder WORKDIR /app COPY package.json package-lock.json* ./ RUN npm ci COPY . . # 构建参数:API 地址(Nginx 反向代理,同域 /api) ENV VITE_API_BASE=/api RUN npm run build # ---- Stage 2: 运行时(Nginx) ---- FROM nginx:alpine # 复制构建产物 COPY --from=builder /app/dist /usr/share/nginx/html # 复制 Nginx 配置 COPY nginx-site.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]