Перейти к содержимому

One Image for Two Chips: Docker BuildKit, buildx and QEMU, July 2022 · 1080p Electronic

Busy Work Labs

0:00 / 0:00

One Image for Two Chips: Docker BuildKit, buildx and QEMU, July 2022 · 1080p Electronic

48 просмотров · 7 дней назад
Busy Work Labs
21 подписчик
48 просмотров · 7 дней назад
A Saturday morning in July 2022 on a Ryzen 7 5800X running Pop!_OS 22.04. Docker Engine 20.10.17, buildx 0.8.2, BuildKit 0.10.3 in a docker-container builder, QEMU registered through tonistiigi/binfmt. There is no Go toolchain on the machine: the compiler lives in golang:1.18.3-bullseye and the result goes into distroless. The job is one tag on a LAN registry that a Raspberry Pi 4 can pull as arm64 and the workstation can pull as amd64. The first build ships a 212 MB context for forty-one Go files, so a three-line .dockerignore gets it down to 1.2 MB. Two platforms on the default driver is an ERROR, so a container builder gets created, binfmt installed, and the emulated build starts: the amd64 half finishes in three minutes, the arm64 half spends 312 seconds on go mod download and 2281 seconds in go build, four qemu-aarch64 processes pinned the whole time. Forty-three minutes for one binary. The fix is three sed lines in the Dockerfile: FROM --platform=$BUILDPLATFORM, ARG TARGETOS TARGETARCH, GOOS and GOARCH on the go build. Both builder stages run native, the arm64 compile takes 58.9 seconds and the layer digests come out byte-identical to the emulated ones. Then cache mounts and a registry cache, a colleague's git pull brings 0.4.1, and the rebuild compiles in 31 seconds. The image gets taken apart with docker export and tar, and the Pi pulls the tag, runs it as uid 65532 with no shell behind it, and serves beacon_build_info{goarch="arm64"} on port 9100. An hour of bright, steady electronic — music only, no typing sounds. 1 hour, 1920×1080, with sound. Music: 'Binary' by Bosnow on #Uppbeat https://uppbeat.io/c/bosnow License code: WJQXLZZTMJS1YOPP Music: 'Infinity' by exekat on #Uppbeat https://uppbeat.io/c/exekat License code: JWMDSLX0QFKE1QA1 #docker #buildkit #buildx #qemu #golang #multiarch #2020s #compiling #busyworklabs #musiconly #ambient #focus #deepwork #programming #codingmusic