gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Consumer: Build and publish multi-arch Docker images

Open mattKorwel opened this issue 5 months ago • 10 comments

This task is to re-engineer our Docker image build process to produce and publish multi-platform images, ensuring native performance and compatibility for users on different CPU architectures.

The Problem

Our current build process, orchestrated by scripts/build_sandbox.js, creates a Docker image for a single architecture (the architecture of the machine running the build). This creates a significant problem for the growing number of users on non-x86 hardware, particularly developers using Apple Silicon (ARM64) machines.

When an amd64 image is run on an arm64 host, Docker must use QEMU for emulation, which is often slow and can introduce subtle bugs. This results in a poor user experience for a large segment of our developer community.

Why Multi-Arch Images Matter

A multi-arch image (also known as a "fat manifest") is a single image tag (e.g., my-image:latest) that points to a list of platform-specific image layers. When a user runs docker pull my-image:latest, Docker automatically selects and pulls the image variant that matches their native architecture. This provides:

  • Native Performance: No emulation is required, so the container runs at full speed.
  • Seamless User Experience: Users don't need to think about architectures or use special tags. It just works.
  • Future-Proofing: As more hardware moves to ARM, having a multi-arch build process is essential.

Recommended Approach

We will use docker buildx, the official Docker tool for multi-platform builds.

  1. Integrate docker buildx: The scripts/build_sandbox.js script (or the CI workflow that calls it) must be updated to use docker buildx build instead of the standard docker build.
  2. Specify Target Platforms: The build command must include the --platform flag to specify all target architectures. We should start with linux/amd64 and linux/arm64.
  3. Push the Manifest: The buildx command must include the --push flag, which builds the images for all platforms and pushes them to the registry under a single manifest list.

Example Command:

docker buildx build \
  --platform linux/amd64,linux/arm64 \
  -t my-registry/my-image:latest \
  --push .

This change will make our sandbox feature faster, more reliable, and accessible to all of our users, regardless of their hardware.

Further Reading:

mattKorwel avatar Jul 10 '25 01:07 mattKorwel