Skip to content

Use CPU-only PyTorch to reduce Docker image size#977

Open
r33drichards wants to merge 3 commits intomainfrom
claude/cpu-only-pytorch-dockerfile-kZkcP
Open

Use CPU-only PyTorch to reduce Docker image size#977
r33drichards wants to merge 3 commits intomainfrom
claude/cpu-only-pytorch-dockerfile-kZkcP

Conversation

@r33drichards
Copy link
Collaborator

Summary

Optimizes the Docker image for the docs-mcp-server by configuring PyTorch to use CPU-only wheels instead of the default CUDA-enabled build, reducing image size by approximately 1.5GB.

Changes

  • Added UV_EXTRA_INDEX_URL environment variable pointing to PyTorch's CPU wheel index
  • Added explanatory comments documenting the rationale for this optimization

Details

The docs-mcp-server doesn't require GPU acceleration, so including CUDA libraries in the PyTorch installation is unnecessary overhead. By configuring the package manager to use CPU-only wheels from PyTorch's official index, we significantly reduce the final image size without sacrificing functionality.

This change improves build times and reduces storage/deployment costs while maintaining full compatibility with the application's requirements.

https://claude.ai/code/session_01JCxwLh9kRhD7jW7SqzfbhJ

Add UV_EXTRA_INDEX_URL environment variable to download PyTorch from
the CPU-only wheel index, reducing image size by ~1.5GB by excluding
unnecessary CUDA libraries.

https://claude.ai/code/session_01JCxwLh9kRhD7jW7SqzfbhJ
@vercel
Copy link
Contributor

vercel bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Feb 2, 2026 10:07am

Request Review

The PyTorch CPU wheel index contains older versions of packages like
requests that conflict with other dependencies. Using unsafe-best-match
allows uv to pick the best compatible version from any index.

https://claude.ai/code/session_01JCxwLh9kRhD7jW7SqzfbhJ
- Add flake.nix that builds a base image with Python 3.12 and uv
- Use CPU-only PyTorch via UV_EXTRA_INDEX_URL for smaller image size
- Update workflow to use Nix + podman for multi-arch builds
- Use skopeo for pushing images to ECR
- Build natively on arm64 and amd64 runners (no cross-compilation)
- Remove Dockerfile in favor of Nix-based image building

https://claude.ai/code/session_01JCxwLh9kRhD7jW7SqzfbhJ
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.

2 participants