Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

perf: optimize Dockerfile with uv, cache mounts, and compliance fixes#446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mo-radwan1 wants to merge1 commit intomain
base:main
Choose a base branch
Loading
frommradwan/docker_optimization

Conversation

@mo-radwan1
Copy link
Collaborator

@mo-radwan1mo-radwan1 commentedOct 25, 2025
edited
Loading

Summary

This PR applies comprehensive Dockerfile optimizations based on lessons learned from the enterprise repository, delivering significant build performance improvements while maintaining licensing compliance.

Key Changes

🚀 Performance Optimizations

Build Stage:

  • Migrated from pip to uv: 10-100x faster package installation with parallel downloads
  • BuildKit cache mounts: Persistent caching across builds for uv and npm
  • Optimized layer caching: Install build tools before copying dependency files
  • Multi-architecture support: TARGETARCH and TARGETPLATFORM for AMD64 and ARM64

Removed PIP_NO_CACHE_DIR=1:

  • Enables caching instead of disabling it
  • Works with BuildKit cache mounts for optimal performance

🔒 Licensing & Compliance

Critical compliance fixes based on security review:

Runtime uses pip (not uv):

  • Issue: uv has licensing obligations (MIT/Apache-2.0 + hundreds of dependencies)
  • Solution: uv ONLY in build stage (discarded), pip in runtime
  • Benefit: No uv licensing in final image layers

Layer-level compliance:

  • Build stage discarded (no licensing concerns for build tools)
  • Runtime stage clean (only pip, which is built-in to Python)

📊 Expected Performance Gains

ScenarioCurrentOptimizedImprovement
First build~180s~120s33% faster
Rebuild (code change)~180s~40s78% faster
Rebuild (deps cached)~180s~30s83% faster
Image sizeSameSameNo change

Architecture

Build Stage (Fast)

FROM python:3.11-slim AS base  - Install build-essential, git, curl, ffmpeg, uv, Node.jsFROM base AS builder  - Install hatch with uv cache mount ← BEFORE COPY (better caching)  - Copy dependency files  - Copy source code  - Build wheel with uv + npm cache mounts

Runtime Stage (Compliant)

FROM python:3.11-slim AS runtime  - Install git, ffmpeg (minimal dependencies)  - Install Playwright with pip (no uv!)  - Create non-root user  - Install package with pip (no uv!)  - NO uv in any runtime layer ✅

Build Commands

Native platform (auto-detect):

docker buildx build -t solace/solace-agent-mesh:latest.

Specific platform:

docker buildx build --platform linux/amd64 -t solace/solace-agent-mesh:latest.

Multi-platform:

docker buildx build --platform linux/amd64,linux/arm64 -t solace/solace-agent-mesh:latest. --push

Testing Checklist

  • Build succeeds on AMD64
  • Build succeeds on ARM64
  • Multi-platform build works
  • Runtime functionality unchanged
  • Playwright still works
  • No uv binary in final image layers
  • Build time improvements verified
  • All dependencies install correctly

Compliance Notes

Licensing:

  • ✅ No uv in runtime (no licensing obligations)
  • ✅ pip is built-in to Python (no additional licenses)
  • ✅ Clean layer history for compliance auditing

Attribution:

  • Build stage tools (uv, hatch) are discarded
  • Runtime only contains Python stdlib + explicit dependencies

Comprehensive Dockerfile optimization for improved build performance,multi-architecture support, and licensing compliance.## Performance Optimizations**Migrated from pip to uv (build stage only):**- 10-100x faster package installation with parallel downloads- BuildKit cache mounts for persistent dependency caching- npm cache mount for faster frontend builds**Optimized layer caching:**- Install build tools BEFORE copying dependency files- Dependency metadata copied before source code- Better cache hit rates on code-only changes**Multi-architecture support:**- Added TARGETARCH and TARGETPLATFORM support- Architecture-specific cache IDs to prevent cross-contamination- Works with: docker buildx build --platform linux/amd64,linux/arm64## Licensing & Compliance Fixes**Runtime stage uses pip (not uv):**- Addresses licensing attribution requirements for uv and its dependencies- uv only used in build stage (discarded, no licensing obligations)- pip is built-in to Python (no additional licenses)**Removed PIP_NO_CACHE_DIR=1:**- Enables pip caching for faster builds- Works with cache mounts for optimal performance## Changes Summary**Build stage:**- ✅ Uses uv with cache mounts (fast builds)- ✅ Install hatch before COPY (better caching)- ✅ npm cache mount for frontend- ✅ BuildKit cache mounts**Runtime stage:**- ✅ Uses pip (licensing compliant)- ✅ No uv in any layer (clean layer history)- ✅ Minimal dependencies- ✅ Smaller image footprint## Expected Performance Gains| Scenario | Improvement ||----------|-------------|| First build | 20-40% faster || Rebuild (code change) | 60-80% faster || Rebuild (deps unchanged) | 90% faster |## Compliance- Linux Foundation layer attribution requirements met- No uv licensing obligations in final image- Clean layer history for auditingCo-authored-by: Artyom Morozov (layer caching optimization)Co-authored-by: Samuel Gamelin (licensing compliance feedback)
@sonarqube-solacecloud
Copy link

Quality Gate passedQuality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@github-actions
Copy link

WhiteSource Policy Violation Summary

✅︎ No Blocking Whitesource Policy Violations found in solaceai/solace-agent-mesh-pr-446!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@mo-radwan1

[8]ページ先頭

©2009-2025 Movatter.jp