From ccfba0df28ab4d5dcace9056469cbc929249696b Mon Sep 17 00:00:00 2001 From: Benson Wong <83972+mostlygeek@users.noreply.github.com> Date: Thu, 4 Jun 2026 14:26:21 -0700 Subject: [PATCH] docker: fix arm64 cpu image downloading amd64 llama-swap binary (#819) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace TARGETARCH build-arg with runtime arch detection via uname -m. BuildKit's TARGETARCH injection was unreliable for the multi-arch cpu build, causing the arm64 image variant to download and embed the x86_64 llama-swap binary — resulting in "exec format error" on arm64 hosts. With QEMU user-space emulation, uname -m correctly returns aarch64 inside an arm64 container build, so the download always fetches the right binary for the actual target architecture. Also adds --fail to curl so HTTP 404s produce a build error instead of silently embedding an HTML error page. fixes #818 Co-authored-by: Claude --- docker/llama-swap.Containerfile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docker/llama-swap.Containerfile b/docker/llama-swap.Containerfile index 7d47e02b..1346fb0b 100644 --- a/docker/llama-swap.Containerfile +++ b/docker/llama-swap.Containerfile @@ -2,10 +2,6 @@ ARG BASE_IMAGE=ghcr.io/ggml-org/llama.cpp ARG BASE_TAG=server-cuda FROM ${BASE_IMAGE}:${BASE_TAG} -# has to be after the FROM -# TARGETARCH is auto-set by `docker buildx build --platform …` (amd64/arm64); -# falls back to amd64 when an older `docker build` runs without buildx. -ARG TARGETARCH=amd64 ARG LS_VER=170 ARG LS_REPO=mostlygeek/llama-swap @@ -37,9 +33,15 @@ WORKDIR /app ENV PATH="/app:${PATH}" RUN \ - curl -LO "https://github.com/${LS_REPO}/releases/download/v${LS_VER}/llama-swap_${LS_VER}_linux_${TARGETARCH}.tar.gz" && \ - tar -zxf "llama-swap_${LS_VER}_linux_${TARGETARCH}.tar.gz" && \ - rm "llama-swap_${LS_VER}_linux_${TARGETARCH}.tar.gz" + set -eux; \ + case "$(uname -m)" in \ + x86_64) ARCH=amd64 ;; \ + aarch64) ARCH=arm64 ;; \ + *) echo "unsupported arch: $(uname -m)" >&2; exit 1 ;; \ + esac; \ + curl --fail -LO "https://github.com/${LS_REPO}/releases/download/v${LS_VER}/llama-swap_${LS_VER}_linux_${ARCH}.tar.gz" && \ + tar -zxf "llama-swap_${LS_VER}_linux_${ARCH}.tar.gz" && \ + rm "llama-swap_${LS_VER}_linux_${ARCH}.tar.gz" COPY --chown=$UID:$GID config.example.yaml /app/config.yaml