airsltd commited on
Commit
ef9fc75
·
1 Parent(s): d130ef2
Files changed (1) hide show
  1. Dockerfile +26 -0
Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用轻量级Node镜像构建阶段
2
+ FROM node:16-alpine AS builder
3
+
4
+ # 安装Git并克隆项目
5
+ RUN apk add --no-cache git
6
+ RUN git clone https://github.com/PanJiaChen/vue-element-admin.git /app
7
+ WORKDIR /app
8
+
9
+ # 配置镜像源并安装依赖(避免使用cnpm)
10
+ RUN npm config set registry https://registry.npmmirror.com \
11
+ && npm install
12
+
13
+ # 构建生产环境静态文件
14
+ RUN npm run build:prod
15
+
16
+ # 使用Nginx镜像部署阶段
17
+ FROM nginx:alpine
18
+
19
+ # 复制构建好的静态文件
20
+ COPY --from=builder /app/dist /usr/share/nginx/html
21
+
22
+ # 使用自定义Nginx配置(可选)
23
+ # COPY nginx.conf /etc/nginx/conf.d/default.conf
24
+
25
+ # 暴露端口
26
+ EXPOSE 80