Files
performance-evaluation-system/Dockerfile
2026-04-11 17:04:49 +08:00

37 lines
786 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 构建阶段
FROM node:20-alpine AS builder
# 设置工作目录
WORKDIR /app
# 复制package.json和package-lock.json
COPY package*.json ./
# 安装依赖
RUN npm ci --only=production --ignore-scripts && \
npm ci --only=development --ignore-scripts
# 复制源代码
COPY . .
# 构建参数API基础URL默认为相对路径 /api通过Nginx代理
ARG VITE_API_BASE_URL=/api
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
# 构建应用
RUN npm run build
# 运行时阶段 - 使用Nginx提供静态文件
FROM nginx:alpine AS runtime
# 复制Nginx配置
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 从构建阶段复制构建产物
COPY --from=builder /app/dist /usr/share/nginx/html
# 暴露端口
EXPOSE 80
# 启动Nginx
CMD ["nginx", "-g", "daemon off;"]