Time_Effectiveness/Dockerfile
2025-10-22 14:36:04 +08:00

35 lines
652 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 docker.1ms.run/node:16 AS builder
# 设置工作目录
WORKDIR /app
# 复制 package.json 和 package-lock.json
COPY package*.json ./
# 安装依赖
RUN npm ci
# 复制所有项目文件
COPY . .
# 创建环境变量文件
RUN touch .env
# 构建应用
RUN npm run build
# 生产阶段
FROM docker.1ms.run/nginx:stable-alpine
RUN rm -rf /usr/share/nginx/html/*
# 复制构建后的文件到Nginx服务器
COPY --from=builder /app/dist /usr/share/nginx/html
# 复制自定义Nginx配置如有需要
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 3001
EXPOSE 3001
# 启动Nginx
CMD ["nginx", "-g", "daemon off;"]