# 使用轻量级Node镜像构建阶段 FROM node:16-alpine AS builder # 安装Git并克隆项目 RUN apk add --no-cache git RUN git clone https://github.com/PanJiaChen/vue-element-admin.git /app WORKDIR /app # 配置镜像源并安装依赖(避免使用cnpm) # RUN npm config set registry https://registry.npmmirror.com \ # && npm install RUN npm install # 构建生产环境静态文件 RUN npm run build:prod # 使用Nginx镜像部署阶段 FROM nginx:alpine # 复制构建好的静态文件 COPY --from=builder /app/dist /usr/share/nginx/html # 使用自定义Nginx配置(可选) COPY nginx.conf /etc/nginx/conf.d/default.conf # 暴露端口 EXPOSE 7860