File size: 677 Bytes
ef9fc75
 
 
 
 
 
 
 
 
e5e214f
 
 
ef9fc75
 
 
 
 
 
 
 
 
 
 
6ed6c59
ef9fc75
 
fe2086d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 使用轻量级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