forked from zgsm-sangfor/site
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (22 loc) · 797 Bytes
/
Copy pathDockerfile
File metadata and controls
35 lines (22 loc) · 797 Bytes
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
29
30
31
32
33
34
35
FROM --platform=$BUILDPLATFORM node:20.19.2 AS builder
WORKDIR /workshop
# 启用 corepack(自动启用 pnpm)
RUN corepack enable
# 配置国内源(可选)
RUN npm config set registry https://registry.npmmirror.com/
COPY package.json pnpm-lock.yaml ./
# 使用 pnpm 安装依赖
RUN pnpm install --frozen-lockfile
COPY . .
# 构建前端
RUN NODE_OPTIONS="--max-old-space-size=4096" npm run build
# ----------------------------
# 第二阶段:使用 Nginx 部署静态文件
# ----------------------------
FROM --platform=$BUILDPLATFORM nginx:stable-alpine AS runner
# RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d/
# 拷贝编译产物到 nginx
COPY --from=builder /workshop/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]