fix(docker): 修复 arm64 镜像内置 x86-64 二进制导致 ARM 服务器无法运行#240
Merged
Conversation
…ip arm64 binaries Every published image (v0.1.0 through v1.1.8) advertised linux/arm64 but contained an x86-64 gateway binary — both platform variants were byte-identical — so the container crashed with "exec format error" on ARM hosts. Root cause: the Dockerfile redeclared TARGETOS/TARGETARCH with default values, which shadow the per-platform values buildx injects, pinning GOARCH=amd64 in both build legs. Drop the defaults so buildx's values apply, pin the webui and Go build stages to $BUILDPLATFORM to cross-compile natively instead of under QEMU emulation, and add a post-push CI step that extracts the binary from each platform variant and fails the workflow if its ELF architecture does not match the advertised one. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
已发布的所有 gateway 镜像(v0.1.0 ~ v1.1.8)虽然 manifest 声明支持
linux/arm64,但 arm64 变体里装的实际是 x86-64 二进制,在 ARM 服务器上启动直接报exec format error。验证方式:分别下载 GHCR 上
latest两个平台变体的最后一层并提取/usr/local/bin/liveagent-gateway:ELF 64-bit LSB executable, x86-64ELF 64-bit LSB executable, x86-64(与 amd64 变体 sha256 完全相同,BuildID 一致)根因
Dockerfile 中重新声明 buildx 自动注入的平台参数时带了默认值:
stage 内带默认值的重声明会遮蔽 buildx 按平台注入的值,导致两条构建腿的
GOARCH都被钉死为amd64。FROM的平台解析本身是正常的(runtime 基础层两个变体各自正确),所以产出了"外壳 arm64、二进制 amd64"的镜像,docker manifest inspect完全看不出异常。修复
TARGETOS/TARGETARCH的默认值,让 buildx 注入的按平台值生效;同时把 webui 和 Go 构建阶段钉到--platform=$BUILDPLATFORM,改为原生交叉编译——此前 arm64 腿的pnpm build和go build都跑在 QEMU 模拟下,纯浪费构建时间。本地make gateway-docker-build(单平台 BuildKit 构建)行为不变,bare ARG 自动取宿主平台值。按需求不处理旧镜像/旧 tag;下一次打 tag 发布即产出真正的双架构镜像(注意
workflow_dispatch重发旧 tag 会 checkout 旧代码,不含本修复)。验证
本机无 docker 后端,未做本地构建;修复采用 Docker 官方文档的标准交叉编译模式,发布时由新增的 CI 校验步骤兜底验证。
🤖 Generated with Claude Code