Skip to content

fix: improve multi-platform support in Containerfile - #31

Merged
c-vigo merged 4 commits into
mainfrom
dev
Jan 28, 2026
Merged

c-vigo merged 4 commits into
mainfrom
dev

Conversation

@c-vigo

@c-vigo c-vigo commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes a critical bug in the Containerfile that prevented multi-platform builds from working correctly. The TARGETARCH ARG had a default value (amd64) that was overriding Docker BuildKit's automatic platform detection, causing builds to download incorrect architecture-specific binaries and fail with "Exec format error".

Related Issue(s)

Closes #

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Test updates

Changes Made

Containerfile (line 60)

  • Before: ARG TARGETARCH=amd64
  • After: ARG TARGETARCH
  • Added clarifying comment explaining that TARGETARCH is automatically provided by Docker BuildKit

Workflow (publish-container-image.yml)

  • Fixed image tagging after podman load in "Load image for testing" step
  • The workflow now explicitly tags the loaded image with the expected name (ghcr.io/vig-os/devcontainer:VERSION-ARCH)
  • This ensures tests can find and use the correct image

CHANGELOG.md

  • Added entry in version 0.2.1 documenting the multi-platform build fix

Root Cause

The default value =amd64 was overriding Docker BuildKit's automatic platform detection. When building for arm64, the build would still use amd64 as the value, causing it to download amd64 binaries (GitHub CLI, uv) which would fail to execute on arm64 with "Exec format error".

Error Symptoms (Before Fix)

Build Error:

#11 1.309 /bin/sh: 1: gh: Exec format error
ERROR: process "/bin/sh -c ... gh --version;" did not complete successfully: exit code: 126

Test Error (after Containerfile fix but before workflow fix):

Loading image from /tmp/image.tar into podman...
Loaded image(s): localhost/99.0.1-arm64:latest
##[error]Process completed with exit code 1.

Podman couldn't find the image with expected tag ghcr.io/vig-os/devcontainer

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

Before the fix:

  • Building for arm64 failed with "Exec format error" when executing downloaded binaries
  • GitHub CLI and uv binaries were incorrectly downloaded as amd64 versions

After the fix:

  • Multi-platform builds complete successfully for both amd64 and arm64
  • Architecture-specific binaries are correctly downloaded based on target platform
  • Images are properly tagged and available for testing
  • Running just clean && just build && just test completes without errors

Verification commands:

# Build for specific architectures
docker buildx build --platform linux/amd64 .
docker buildx build --platform linux/arm64 .

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (README.md, CONTRIBUTE.md, etc.)
  • I have updated the CHANGELOG.md in the [Unreleased] section
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Impact

This is a critical fix that enables the multi-platform container image publishing workflow to function correctly. Without this fix:

  • ARM64 builds would always fail
  • Multi-architecture manifests could not be created
  • The project could only be built for amd64 architecture

Technical Details

Docker BuildKit provides several built-in ARGs for multi-platform builds:

  • TARGETPLATFORM - e.g., linux/amd64, linux/arm64
  • TARGETOS - e.g., linux
  • TARGETARCH - e.g., amd64, arm64

These ARGs are automatically set based on the --platform flag. By declaring ARG TARGETARCH without a default value, we allow BuildKit to inject the correct value for each platform being built.

@c-vigo c-vigo self-assigned this Jan 28, 2026
@c-vigo
c-vigo merged commit 153c0d0 into main Jan 28, 2026
@c-vigo
c-vigo deleted the dev branch January 28, 2026 10:19
c-vigo added a commit that referenced this pull request Feb 13, 2026
After pushing, GitHub rewrites `#31` to `[#31](URL)` in commit
messages. The Refs line validator now accepts both plain and
linked formats.

Refs: #51
@c-vigo c-vigo mentioned this pull request Jul 20, 2026
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.

1 participant