| 12345678910111213141516171819202122232425262728293031323334 |
- FROM node:20 AS builder
- WORKDIR /app
- COPY package*.json ./
- RUN npm config set registry https://registry.npmmirror.com
- RUN npm install
- COPY . .
- ARG ENV=production
- ENV NODE_ENV=$ENV
- ENV VITE_APP_ENV=$ENV
- RUN npm run build
- FROM nginx:alpine
- # 安装必要的工具
- RUN apk add --no-cache curl
- COPY --from=builder /app/dist /usr/share/nginx/html
- # 复制 Nginx 配置
- COPY nginx.conf /etc/nginx/conf.d/default.conf
- # 创建 SSL 目录
- RUN mkdir -p /etc/nginx/ssl
- # 暴露端口
- EXPOSE 80 443
- # 启动 nginx
- CMD ["nginx", "-g", "daemon off;"]
|