Dockerfile 657 B

12345678910111213141516171819202122232425262728
  1. # 使用 Node 镜像构建 Vue 项目
  2. FROM node:20-alpine AS build-stage
  3. # 设置工作目录
  4. WORKDIR /app
  5. # 复制项目文件
  6. COPY ../../../ .
  7. RUN npm install -g pnpm
  8. RUN cd ${WORKDIR}
  9. RUN pnpm install
  10. # 构建生产环境静态文件
  11. RUN build-backend-html
  12. RUN build-web
  13. # 使用 Nginx 镜像作为运行时
  14. FROM nginx:alpine
  15. # 复制 Nginx 配置文件
  16. COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
  17. # 从构建阶段复制静态文件到 Nginx 的默认静态文件目录
  18. COPY --from=build-stage /app/dist /usr/share/nginx/html/admin
  19. # 暴露 80 端口
  20. EXPOSE 80
  21. # 启动 Nginx
  22. CMD ["nginx", "-g", "daemon off;"]