Files
meshcore-analyzer/tests/unit
JadeandClaude d1bf4ca042 fix(docker): build natively on arm64 hosts (#2359)
Building the image natively on an arm64 machine (a Raspberry Pi 4 or 5
on 64-bit OS, Apple silicon) fails at the first `RUN` of the build
stage:

```
=> ERROR [builder  2/40] RUN apk add --no-cache curl xz && ...
0.841 exec /bin/sh: exec format error
```

**Cause:** the Dockerfile declares `ARG BUILDPLATFORM=linux/amd64`. A
default on that ARG overrides the value BuildKit sets for the machine
doing the build, so an arm64 host pulls the amd64 `golang` image and
can't run it. CI didn't catch it because its arm64 image is cross-built
on an amd64 runner, where `linux/amd64` was correct anyway.

**Fix:** declare `ARG BUILDPLATFORM` without a default. BuildKit, the
default builder since Docker 23 and what buildx uses, fills it in on
every host. amd64 builds and the CI cross-build are unchanged.

**Workaround on current master:** `docker build --build-arg
BUILDPLATFORM=linux/arm64 .`

**Test:** `tests/unit/test-dockerfile-buildplatform.js` fails on the old
Dockerfile and passes on this one. It checks three things:
- `BUILDPLATFORM` has no default.
- The Go builder stays pinned to `$BUILDPLATFORM`.
- No stage hard-codes a platform.

It's wired into `test-all.sh`.

Found while building the image on a Raspberry Pi running Raspberry Pi OS
Trixie (arm64) with Docker 29.


---

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-31 12:13:29 +01:00
..