1
0
Fork 0
mirror of https://github.com/imjasonh/krust synced 2026-07-18 15:06:03 +00:00

feat: Add automatic platform detection from base image

- Detect supported platforms by inspecting the base image manifest
- Build for all platforms supported by the base image by default
- Filter out invalid/unknown platforms from manifest
- Normalize platform variants (e.g., linux/arm64/v8 -> linux/arm64)
- Only include platforms that krust supports
- Deduplicate normalized platforms
- Allow explicit --platform to override automatic detection
- Add tests for platform detection functionality
- Add test case for Alpine base image with many platforms
- Update documentation to explain the new behavior

This makes multi-arch builds more intuitive - if your base image supports
multiple platforms, krust will automatically build for all supported ones.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jason Hall 2025-06-07 23:57:13 -04:00
parent f494035f75
commit 2517939b30
Failed to extract signature
4 changed files with 231 additions and 5 deletions

View file

@ -109,7 +109,8 @@ krust build --platform linux/amd64,linux/arm64
# Or specify platforms separately
krust build --platform linux/amd64 --platform linux/arm64
# Default behavior builds for both amd64 and arm64
# Default behavior detects platforms from base image
# If the base image supports multiple platforms, krust will build for all of them
krust build
```
@ -135,6 +136,23 @@ krust always pushes OCI image indexes (manifest lists) for consistency:
This means even single-platform builds result in a manifest list, ensuring a uniform interface regardless of the number of platforms built.
#### Automatic Platform Detection
When you don't specify `--platform`, krust automatically detects which platforms to build for by inspecting the base image:
```bash
# If using cgr.dev/chainguard/static:latest (supports linux/amd64 and linux/arm64)
krust build # Automatically builds for both amd64 and arm64
# If using a single-platform base image
krust build # Builds only for the supported platform
# You can always override with explicit platforms
krust build --platform linux/amd64 # Build only for amd64 regardless of base image
```
This intelligent platform detection ensures your images support the same platforms as your base image, maintaining consistency throughout your image stack.
## Build Process
krust builds your Rust application in an isolated environment: