refactor: use minimal distroless base image to reduce image size #495
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR optimizes the Docker image size by 73%, reducing it from 95.5MB to ~25-28MB while maintaining full functionality and FIPS compliance across both x86_64 and ARM64 platforms.
Cross-Platform Optimization Results
Optimization Journey & Testing Results
We systematically tested multiple approaches to find the optimal solution:
Key Findings
/lib64
and/usr/lib64
Changes Made
Dockerfile Optimization
mcr.microsoft.com/azurelinux/base/core:3.0
(95.5MB)mcr.microsoft.com/azurelinux/distroless/minimal:3.0
(25-28MB)Cross-Platform Technical Implementation
The solution uses multi-stage build with platform-agnostic library copying:
Platform-specific dynamic linkers supported:
/usr/lib/ld-linux-x86-64.so.2
/lib/ld-linux-aarch64.so.1
Essential libraries included:
libc.so.6
,libdl.so.2
,libpthread.so.0
- Core runtimelibresolv.so.2
,librt.so.1
- Network and real-time supportlibssl.so*
,libcrypto.so*
- FIPS complianceBuild Context Optimization
.dockerignore
fileComprehensive Testing
Cross-Platform Validation
Docker Container Functionality Tests
Integration Tests
Authentication Testing
Validated multiple auth approaches on both platforms:
az acr login --expose-token
(chosen solution)Performance Testing
Benefits
Compatibility
Performance Impact
Testing Infrastructure Added
Added
scripts/experimental/test-purge-docker.sh
with comprehensive test coverage: