# 智能项目定价模型 - 前端 Dockerfile # 遵循瑞小美部署规范:使用具体版本号,配置阿里云镜像源 # 构建阶段 FROM node:20.11-alpine AS builder # 构建参数 - API 地址 ARG VITE_API_BASE_URL=/api/v1 # 设置工作目录 WORKDIR /app # 配置阿里云 npm 源 RUN npm config set registry https://registry.npmmirror.com # 安装 pnpm RUN npm install -g pnpm RUN pnpm config set registry https://registry.npmmirror.com # 复制依赖文件 COPY package.json pnpm-lock.yaml* ./ # 安装依赖 RUN pnpm install # 复制源代码 COPY . . # 设置构建时环境变量 ENV VITE_API_BASE_URL=$VITE_API_BASE_URL # 构建 RUN pnpm build # 运行阶段 FROM nginx:1.25.3-alpine AS runner # 复制构建产物 COPY --from=builder /app/dist /usr/share/nginx/html # 复制 nginx 配置 COPY nginx.conf /etc/nginx/conf.d/default.conf # 设置时区 ENV TZ=Asia/Shanghai # 暴露端口 EXPOSE 80 # 健康检查 HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost/ || exit 1 # 启动 nginx CMD ["nginx", "-g", "daemon off;"]