File tree 2 files changed +29
-11
lines changed
2 files changed +29
-11
lines changed Original file line number Diff line number Diff line change 10
10
11
11
jobs :
12
12
build :
13
- runs-on : ubuntu-latest
13
+ strategy :
14
+ matrix :
15
+ include :
16
+ - platform : linux/amd64
17
+ runner : ubuntu-latest
18
+ - platform : linux/arm64
19
+ runner : ubuntu-24.04-arm
20
+ runs-on : ${{ matrix.runner }}
14
21
permissions :
15
22
contents : read
16
23
packages : write
@@ -19,11 +26,10 @@ jobs:
19
26
- name : Checkout repository
20
27
uses : actions/checkout@v4
21
28
22
- - name : Set up QEMU
23
- uses : docker/setup-qemu-action@v3
24
-
25
29
- name : Set up Docker Buildx
26
30
uses : docker/setup-buildx-action@v3
31
+ with :
32
+ platforms : ${{ matrix.platform }}
27
33
28
34
- name : Log in to Docker Hub
29
35
uses : docker/login-action@v3
47
53
with :
48
54
context : .
49
55
push : true
50
- platforms : linux/amd64,linux/arm64
56
+ platforms : ${{ matrix.platform }}
51
57
tags : ${{ steps.meta.outputs.tags }}
52
58
labels : ${{ steps.meta.outputs.labels }}
53
- cache-from : type=gha
54
- cache-to : type=gha,mode=max
59
+ cache-from : |
60
+ type=gha,scope=${{ matrix.platform }}
61
+ cache-to : |
62
+ type=gha,mode=max,scope=${{ matrix.platform }}
63
+ target : runner # 只构建到最终阶段
Original file line number Diff line number Diff line change 1
- FROM node:20-alpine AS builder
1
+ FROM node:20-alpine AS deps
2
2
3
3
WORKDIR /app
4
4
5
+ # 只复制依赖相关文件
5
6
COPY package.json pnpm-lock.yaml ./
6
7
RUN npm i -g --force pnpm@9
7
- RUN pnpm install --frozen-lockfile
8
+ RUN pnpm install --frozen-lockfile --prod
9
+
10
+ FROM node:20-alpine AS builder
11
+ WORKDIR /app
8
12
13
+ COPY --from=deps /app/node_modules ./node_modules
9
14
COPY . .
15
+
10
16
ENV NODE_OPTIONS="--max_old_space_size=2048"
17
+ RUN npm i -g --force pnpm@9
18
+ RUN pnpm install --frozen-lockfile
11
19
RUN pnpm build:optimize
12
20
13
21
FROM node:20-alpine AS runner
14
-
15
22
WORKDIR /app
16
23
17
- # We only need the `.output` directory, which contains everything the app needs to run
24
+ ENV NODE_ENV production
25
+
26
+ # 只复制必要的文件
18
27
COPY --from=builder /app/.output .output
19
28
COPY --from=builder /app/package.json .
20
29
You can’t perform that action at this time.
0 commit comments