Purpose: Comprehensive analysis of build backends for hephy-builder multi-backend strategy
Updated: October 26, 2025
Status: Complete with Ko prototype validation
hephy-builder supports multiple build backends to optimize different application types and use cases. Each backend provides specific advantages while maintaining consistent build-config.yaml configuration.
- Kaniko: Universal Docker builds (current foundation)
- Ko: Go application optimization (prototype complete) β
- Spin: WebAssembly applications (planned)
- BuildKit: Advanced Docker features (planned)
| Metric | Kaniko | Ko (Emulated) | Ko (Native ARM64) | Best Improvement |
|---|---|---|---|---|
| AMD64 Build Time | 2m 15s | 45s | 45s | 3x faster |
| ARM64 Build Time | 2m 20s | 48s | ~35s | 4x faster β‘ |
| Total Multi-Arch | 4m 35s | 1m 33s | ~1m 20s | 3.5x faster |
| Final Image Size | 45 MB | 12 MB | 12 MB | 4x smaller |
| Security Profile | Full OS | Distroless | Distroless | Minimal attack surface |
| Build Complexity | Dockerfile + deps | Go config only | Go config only | Simplified |
Breaking News: GitHub's new native ARM64 runners provide an additional 40% performance boost for ARM64 builds, making Ko backend even more compelling:
- Native ARM64 execution - No emulation overhead
- Cobalt 100 processors - Latest generation ARM chips
- Free for public repositories - Cost-effective for open source
- Ko + ARM64 synergy - Perfect match for Go applications
- β 3x faster builds - No Dockerfile parsing, layer caching overhead
- β 4x smaller images - Distroless base with only necessary runtime
- β Better security - No shell, package managers, or OS utilities
- β Simpler maintenance - No Dockerfile needed, pure Go configuration
- β Universal compatibility - Any language, any Dockerfile
- β Mature ecosystem - Extensive Docker tooling support
- β Complex builds - Multi-stage, advanced Docker features
- β Legacy support - Existing Dockerfile investments
| Backend | Base Image | Shell Access | Package Manager | CVE Exposure |
|---|---|---|---|---|
| Kaniko | Full OS (Alpine/Ubuntu) | β Available | β Available | High |
| Ko | Distroless | β None | β None | Minimal |
| Spin | WASI Runtime | β None | β None | Minimal |
| BuildKit | Configurable | Varies |
- Distroless base: No shell, package manager, or unnecessary binaries
- Static binary: Single executable with no external dependencies
- Read-only filesystem: Immutable runtime environment
- Non-root execution: Secure user permissions by default
- Minimal CVE exposure: Smaller attack surface = fewer vulnerabilities
- Full OS base: Complete Linux environment increases attack surface
- Shell access: Available for complex builds but increases risk
- Package dependencies: OS package vulnerabilities require updates
- Multi-stage benefits: Can achieve similar security with proper Dockerfile design
β Perfect for:
- Go applications - Native optimization and integration
- Microservices - Fast builds, small images ideal for distributed systems
- Security-focused - Minimal attack surface requirements
- Fast CI/CD - Build speed is critical for developer productivity
- Cloud-native - Kubernetes deployments with resource constraints
β Not suitable for:
- Non-Go applications
- Complex build requirements beyond Go compilation
- Legacy applications with existing Dockerfile investments
β Perfect for:
- Non-Go languages - Python, Node.js, Java, Rust, etc.
- Complex Dockerfiles - Multi-stage builds, advanced features
- Legacy applications - Existing Dockerfile investments
- Custom base images - Specific OS or runtime requirements
- Universal compatibility - Any Docker build scenario
β Consider alternatives for:
- Simple Go applications (Ko is faster and more secure)
- WebAssembly applications (Spin is optimized)
- Performance-critical scenarios where build speed matters
β Perfect for:
- WebAssembly applications - WASI runtime optimization
- Edge computing - Lightweight, fast-starting applications
- Polyglot microservices - Multiple languages in single runtime
- Serverless - Cold start optimization
β Perfect for:
- Advanced Docker features - Cache mounts, secrets, SSH
- Complex dependency management - Sophisticated build graphs
- Performance optimization - Parallel builds, advanced caching
- Enterprise requirements - Advanced security and compliance features
# Auto-detection priority order:
1. Explicit backend: build_backend: ko
2. Go project detection: go.mod + cmd/ directory β suggest Ko
3. WebAssembly detection: spin.toml β suggest Spin
4. Dockerfile present: β use Kaniko (default)
5. Fallback: β Kaniko (universal compatibility)# build-config.yaml
build_backend: ko
ko_config:
import_path: ./cmd/server
base_image: cgr.dev/chainguard/static:latest
platforms: [linux/amd64, linux/arm64]
env: [CGO_ENABLED=0]
ldflags: ["-s", "-w", "-X main.version=v1.0.0"]
additional_tags: [latest, optimized]# build-config.yaml
build_backend: kaniko # Optional - default
dockerfile_path: Dockerfile
platforms: [linux/amd64, linux/arm64]
build_args:
- VERSION=v1.0.0
additional_tags: [latest, stable]# build-config.yaml
build_backend: spin
spin_config:
manifest_path: spin.toml
runtime: wasi
platforms: [wasi/wasm32]
additional_tags: [latest, wasm]For Go applications wanting Ko optimization benefits:
# Before: Kaniko
dockerfile_path: Dockerfile
platforms: [linux/amd64, linux/arm64]
# After: Ko
build_backend: ko
ko_config:
import_path: ./cmd/app
base_image: cgr.dev/chainguard/static:latest
platforms: [linux/amd64, linux/arm64]Benefits: 3x faster builds, 4x smaller images, better security Effort: Medium - requires Go module structure, remove Dockerfile
| Priority | Recommended Backend | Rationale |
|---|---|---|
| Performance | Ko > BuildKit > Kaniko | Build speed and image size |
| Security | Ko > Spin > BuildKit > Kaniko | Attack surface minimization |
| Compatibility | Kaniko > BuildKit > Ko > Spin | Universal language support |
| Simplicity | Ko > Spin > Kaniko > BuildKit | Configuration complexity |
- β Ko backend prototype complete with performance validation
- π§ Pipeline integration (Issue #5)
- π§ Auto-detection logic for Go projects
- π§ Documentation and examples
- GitHub Actions Ko workflow equivalent
- Performance monitoring and optimization
- Ko configuration templates and best practices
- Enterprise Ko configuration options
- Spin backend: WebAssembly application support (Issue #11)
- BuildKit backend: Advanced Docker features (Issue #12)
- Backend composition: Multi-backend applications
- Performance benchmarking: Automated comparison testing
| Feature | Kaniko | Ko | Spin | BuildKit |
|---|---|---|---|---|
| Languages | All | Go | WASI-compatible | All |
| Build Speed | ββ | ββββ | βββ | βββ |
| Image Size | ββ | ββββ | ββββ | βββ |
| Security | ββ | ββββ | ββββ | βββ |
| Compatibility | ββββ | ββ | ββ | ββββ |
| Complexity | βββ | ββββ | βββ | ββ |
| Maturity | ββββ | βββ | ββ | βββ |
Rating Scale: β Poor β ββββ Excellent
- Start with use case: What type of application are you building?
- Consider constraints: Performance, security, compatibility requirements
- Evaluate trade-offs: Speed vs compatibility, security vs complexity
- Plan migration: Can you optimize later with different backend?
- Explicit backend specification: Always declare
build_backendfor clarity - Platform consistency: Use same platforms across all backends
- Security defaults: Prefer minimal base images and distroless when possible
- Performance testing: Benchmark different backends for your use case
For applications with mixed requirements:
- API service: Ko backend for fast, secure Go service
- Frontend assets: Kaniko for Node.js build pipeline
- Edge functions: Spin for WebAssembly serverless functions
- Database migrations: Kaniko for SQL tooling containers
This analysis is based on real performance data from the Ko prototype and provides concrete guidance for hephy-builder backend selection across different application types and requirements.