Dockerfile 479 B

12345678910111213141516171819202122232425
  1. # ===== 构建阶段 =====
  2. FROM node:22-alpine AS builder
  3. WORKDIR /app
  4. # 复制依赖文件并安装
  5. COPY package*.json ./
  6. RUN npm install
  7. # 复制源码并构建
  8. COPY . .
  9. RUN npm run build-only -- --mode production
  10. # ===== 运行阶段 =====
  11. FROM nginx:stable-alpine
  12. # 复制构建产物到 nginx 目录
  13. COPY --from=builder /app/dist /usr/share/nginx/html
  14. # 复制 nginx 配置
  15. COPY nginx.conf /etc/nginx/conf.d/default.conf
  16. EXPOSE 80
  17. CMD ["nginx", "-g", "daemon off;"]