Skip to content

Build tonistiigi/binfmt image from source#763

Merged
hjiawei merged 1 commit intoprojectcalico:masterfrom
hjiawei:binfmt
Jan 26, 2026
Merged

Build tonistiigi/binfmt image from source#763
hjiawei merged 1 commit intoprojectcalico:masterfrom
hjiawei:binfmt

Conversation

@hjiawei
Copy link
Collaborator

@hjiawei hjiawei commented Jan 24, 2026

This change imports the tonistiigi/binfmt source into our toolchain and rebuilds the cross-platform emulator collection image using qemu-user-static from Fedora.

@hjiawei hjiawei force-pushed the binfmt branch 2 times, most recently from 425d277 to 1be9f5c Compare January 24, 2026 22:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for building the tonistiigi/binfmt image from source rather than using a pre-built external image. This improves security, reproducibility, and control over the binfmt tooling used for multi-architecture container builds.

Changes:

  • Introduces a new calico-binfmt image that bundles QEMU user-static binaries from Fedora and a custom binfmt binary built from Go source code
  • Adds binfmt command-line tool (ported from tonistiigi/binfmt) to manage binfmt_misc registrations for cross-architecture emulation
  • Updates CI/CD pipelines to build and publish the new binfmt image alongside existing base and go-build images

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
images/calico-binfmt/versions.yaml Defines version pins for QEMU (10.1.3) and tonistiigi-binfmt source reference (commit 49eb232)
images/calico-binfmt/Dockerfile Multi-stage build that installs QEMU binaries from Fedora and packages them with the binfmt binary
images/Makefile Adds build targets for calico-binfmt image, updates clean target and image dependencies
go.mod Updates Go version to 1.25.6 and adds dependencies for platforms, buildkit, and image-spec libraries
go.sum Adds checksums for new dependencies and updates existing ones (logrus, testify, sys, yaml)
cmd/binfmt/version.go Defines version variables injected at build time via ldflags
cmd/binfmt/main.go Main implementation of binfmt CLI tool for installing/uninstalling architecture emulation support
cmd/binfmt/config.go Configuration data for supported architectures including ELF magic bytes and masks for QEMU registration
cmd/Makefile Adds build target for binfmt binary with version information from versions.yaml
.semaphore/semaphore.yml Adds CI job to build calico/binfmt image and updates promotion configuration
.semaphore/promotions/calico-binfmt.yml Defines CI/CD pipeline for publishing calico/binfmt images
.gitignore Adds images/calico-binfmt/bin to ignore list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mask string
}

var configs = map[string]config{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only support the amd64, arm64, s390x, and ppc64le platforms. All other platforms have been commented out to reduce potential merge conflicts in the future.

Comment on lines +11 to +14
COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64
COPY --from=qemu /usr/bin/qemu-ppc64le-static /usr/bin/qemu-ppc64le
COPY --from=qemu /usr/bin/qemu-s390x-static /usr/bin/qemu-s390x
COPY --from=qemu /usr/bin/qemu-x86_64-static /usr/bin/qemu-x86_64
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only support the amd64, arm64, s390x, and ppc64le platforms.


# qemu-user-static package version from Fedora
QEMU_VERSION ?= $(shell yq -r '.qemu.version' calico-binfmt/versions.yaml)
CALICO_BINFMT_IMAGETAG ?= qemu-v$(QEMU_VERSION)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using latest, I’ve tagged the image using the qemu-vx.y.z scheme. The current tag is calico/binfmt:qemu-v10.1.3.

@hjiawei hjiawei merged commit d8d9464 into projectcalico:master Jan 26, 2026
8 checks passed
@hjiawei hjiawei deleted the binfmt branch January 26, 2026 22:05
@hjiawei
Copy link
Collaborator Author

hjiawei commented Jan 26, 2026

Related to tonistiigi/binfmt#285.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants