Skip to content

Commit 4d07fec

Browse files
authored
Merge pull request Stack-Cairn#240 from Stack-Cairn/fix/docker-arm64-image
fix(docker): 修复 arm64 镜像内置 x86-64 二进制导致 ARM 服务器无法运行
2 parents f4f90da + b66fc18 commit 4d07fec

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

.github/workflows/gateway-docker.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,25 @@ jobs:
6161
cache-from: type=gha
6262
cache-to: type=gha,mode=max
6363
provenance: false
64+
65+
# Guard against mislabeled variants: v0.1.0 through v1.1.8 advertised
66+
# arm64 while shipping an x86-64 binary (TARGETARCH defaults in the
67+
# Dockerfile shadowed the values buildx injects).
68+
- name: Verify per-arch binaries
69+
run: |
70+
set -euo pipefail
71+
image="$(echo "$IMAGE_NAME" | tr '[:upper:]' '[:lower:]')@${{ steps.push.outputs.digest }}"
72+
for arch in amd64 arm64; do
73+
case "$arch" in
74+
amd64) want="x86-64" ;;
75+
arm64) want="aarch64" ;;
76+
esac
77+
docker pull --platform "linux/$arch" "$image" >/dev/null
78+
docker rm -f "verify-$arch" >/dev/null 2>&1 || true
79+
docker create --platform "linux/$arch" --name "verify-$arch" "$image" >/dev/null
80+
docker cp "verify-$arch:/usr/local/bin/liveagent-gateway" "/tmp/gateway-$arch"
81+
docker rm -f "verify-$arch" >/dev/null
82+
info="$(file -b "/tmp/gateway-$arch")"
83+
echo "linux/$arch: $info"
84+
echo "$info" | grep -q "$want" || { echo "::error::linux/$arch image contains a non-$arch gateway binary"; exit 1; }
85+
done

Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1.7
22

3-
FROM node:22.17.1-bookworm-slim AS webui
3+
FROM --platform=$BUILDPLATFORM node:22.17.1-bookworm-slim AS webui
44

55
WORKDIR /src/crates/agent-gateway/web
66
RUN npm install -g pnpm@10.32.1
@@ -11,10 +11,11 @@ RUN pnpm install --frozen-lockfile
1111
COPY crates/agent-gateway/web ./
1212
RUN pnpm build
1313

14-
FROM golang:1.25-bookworm AS gateway-builder
14+
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS gateway-builder
1515

16-
ARG TARGETOS=linux
17-
ARG TARGETARCH=amd64
16+
# Keep these ARGs bare: a default value shadows the per-platform values buildx injects.
17+
ARG TARGETOS
18+
ARG TARGETARCH
1819

1920
WORKDIR /src/crates/agent-gateway
2021

0 commit comments

Comments
 (0)