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