Skip to content

Use uv bytecode compilation across sample Dockerfiles - #1166

Draft
Wenxing Zhu (Wixee) wants to merge 2 commits into
mainfrom
uv-compile
Draft

Wenxing Zhu (Wixee) wants to merge 2 commits into
mainfrom
uv-compile

Conversation

@Wixee

@Wixee Wenxing Zhu (Wixee) commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Use uv's built-in --compile-bytecode during frozen dependency installation across all uv-based sample Dockerfiles instead of separate manual compilation commands.

  • Add the flag where missing and remove all manual bytecode compilation from these Dockerfiles.
  • Preserve startup and PYTHONDONTWRITEBYTECODE guidance next to dependency installation. Clarify that the variable disables automatic writes on import, but Python can still read valid .pyc files.
  • Clarify that uv compiles site-packages only. Unlike the removed manual passes, it does not precompile the standard library or copied application code, or perform a strict application syntax check.
  • Leave pip-only Dockerfiles, dependency versions, lockfiles, base images, cleanup steps, and entrypoints unchanged.

Related: #1153.

Validation

  • Frozen sync dry-runs passed with uv 0.11.7 and each Dockerfile's Python minor version across all uv-based sample Dockerfiles.
  • Shell-form Docker RUN syntax checks passed with Bash.
  • Verified .pyc generation and dependency import with bytecode writes disabled in an isolated uv-managed environment.
  • Full Docker builds were not run because the local Docker daemon is unavailable.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the Dockerfile bytecode-compilation simplification.

No open issues 🎉

What changed in this PR

Simplifies bytecode precompilation in ten Python hosted-agent Dockerfiles, following the cold-start optimization work in #1153.

Changes:

  • Adds --compile-bytecode to frozen uv dependency installation and removes separate compileall commands.
  • Limits precompilation to dependencies, dropping standard-library/application compilation and strict application syntax checks.
  • Updates cold-start and PYTHONDONTWRITEBYTECODE guidance while leaving dependency versions, base images, and entrypoints unchanged.
File Description
samples/​python/​hosted-agents/​langgraph/​responses/​15-branching/​src/​langgraph-branching/​Dockerfile Uses uv bytecode compilation for the branching sample.
samples/​python/​hosted-agents/​langgraph/​responses/​14-middleware/​src/​langgraph-middleware/​Dockerfile Uses uv bytecode compilation for the middleware sample.
samples/​python/​hosted-agents/​langgraph/​responses/​13-custom-store/​src/​custom-store/​Dockerfile Uses uv bytecode compilation for the custom-store sample.
samples/​python/​hosted-agents/​langgraph/​responses/​11-deep-agents/​src/​langgraph-deep-agents/​Dockerfile Uses uv bytecode compilation for the deep-agents sample.
samples/​python/​hosted-agents/​langgraph/​responses/​10-run/​src/​langgraph-run-responses/​Dockerfile Uses uv bytecode compilation for the responses runner.
samples/​python/​hosted-agents/​langgraph/​responses/​09-resilient/​src/​langchain-azure-resilient-responses/​Dockerfile Uses uv bytecode compilation for resilient responses.
samples/​python/​hosted-agents/​langgraph/​responses/​08-observability/​src/​langgraph-observability-responses/​Dockerfile Uses uv bytecode compilation for the observability sample.
samples/​python/​hosted-agents/​langgraph/​invocations/​03-run/​src/​langgraph-run-invocations/​Dockerfile Uses uv bytecode compilation for the invocations runner.
samples/​python/​hosted-agents/​langgraph/​invocations/​02-resilient/​src/​langchain-azure-resilient-invocations/​Dockerfile Uses uv bytecode compilation for resilient invocations.
samples/​python/​hosted-agents/​agent-framework/​responses/​22-foundry-toolbox-mcp-skills/​src/​agent-framework-agent-foundry-toolbox-mcp-skills-responses/​Dockerfile Uses uv bytecode compilation for the Agent Framework toolbox-skills sample.

Review effort: Balanced

@Wixee
Wenxing Zhu (Wixee) marked this pull request as draft November 13, 2026 09:47
@Wixee Wenxing Zhu (Wixee) changed the title Use uv bytecode compilation in hosted-agent Dockerfiles Use uv bytecode compilation across sample Dockerfiles Nov 13, 2026

This branch was successfully deployed

1 active deployment
L4-validation — d21cbf7f Deployed Nov 13, 2026 by Wixee via trusted #987
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