Files
Scoring-System/frontend/Dockerfile
爽哒哒 e3a620b395
All checks were successful
Deploy to Server / deploy (push) Successful in 19s
chore: 优化 Docker 配置,添加生产环境部署脚本和文档
2026-03-18 22:48:36 +08:00

35 lines
634 B
Docker

# 构建阶段
FROM node:20-alpine AS builder
# 设置工作目录
WORKDIR /app
# 安装依赖
COPY package.json package-lock.json* ./
RUN npm install --registry=https://registry.npmmirror.com
# 复制项目文件
COPY . .
# 接收构建参数
ARG VITE_API_URL=/api
ENV VITE_API_URL=${VITE_API_URL}
# 构建生产环境代码
RUN npm run build
# 生产阶段 - 使用 Nginx
FROM nginx:alpine
# 复制 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;"]