Skip to content

Commit cbbc005

Browse files
committed
perf: 使用 Go 原生交叉编译加速多架构构建
1 parent 066800b commit cbbc005

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ RUN npm run build
2020
# ============================================
2121
# Stage 2: Backend Builder
2222
# ============================================
23-
FROM golang:1.23-alpine AS backend-builder
23+
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS backend-builder
24+
25+
# 接收目标平台参数
26+
ARG TARGETOS
27+
ARG TARGETARCH
2428

2529
WORKDIR /build
2630

@@ -35,8 +39,8 @@ RUN go mod download
3539
COPY . .
3640

3741
# Build binary with optimizations
38-
# CGO_ENABLED=0 for pure Go SQLite (modernc.org/sqlite)
39-
RUN CGO_ENABLED=0 GOOS=linux go build \
42+
# 使用 Go 原生交叉编译,而非 QEMU 模拟
43+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \
4044
-trimpath \
4145
-ldflags="-s -w" \
4246
-o bitwarden-backup \

0 commit comments

Comments
 (0)