From 2f8a416cd02b5ee820b51c8051f160a305c08452 Mon Sep 17 00:00:00 2001 From: Wenxing Zhu Date: Fri, 13 Nov 2026 17:36:57 +0800 Subject: [PATCH 1/2] Use uv bytecode compilation in hosted-agent Dockerfiles --- .../Dockerfile | 21 +++++++------------ .../Dockerfile | 21 +++++++------------ .../src/langgraph-run-invocations/Dockerfile | 21 +++++++------------ .../Dockerfile | 21 +++++++------------ .../Dockerfile | 21 +++++++------------ .../src/langgraph-run-responses/Dockerfile | 21 +++++++------------ .../src/langgraph-deep-agents/Dockerfile | 21 +++++++------------ .../src/custom-store/Dockerfile | 21 +++++++------------ .../src/langgraph-middleware/Dockerfile | 21 +++++++------------ .../src/langgraph-branching/Dockerfile | 21 +++++++------------ 10 files changed, 70 insertions(+), 140 deletions(-) diff --git a/samples/python/hosted-agents/agent-framework/responses/22-foundry-toolbox-mcp-skills/src/agent-framework-agent-foundry-toolbox-mcp-skills-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/22-foundry-toolbox-mcp-skills/src/agent-framework-agent-foundry-toolbox-mcp-skills-responses/Dockerfile index 1212c9d2b..561d222be 100644 --- a/samples/python/hosted-agents/agent-framework/responses/22-foundry-toolbox-mcp-skills/src/agent-framework-agent-foundry-toolbox-mcp-skills-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/22-foundry-toolbox-mcp-skills/src/agent-framework-agent-foundry-toolbox-mcp-skills-responses/Dockerfile @@ -7,23 +7,16 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile Python bytecode at build time so cold starts don't pay for it. +# uv compiles site-packages, not the stdlib or application code. Slim base +# images ship little precompiled stdlib bytecode, so those imports may still +# compile on first use. +# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled +# .pyc files still benefit images that set it. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/langgraph/invocations/02-resilient/src/langchain-azure-resilient-invocations/Dockerfile b/samples/python/hosted-agents/langgraph/invocations/02-resilient/src/langchain-azure-resilient-invocations/Dockerfile index 13c1a8dfc..3ba24012c 100644 --- a/samples/python/hosted-agents/langgraph/invocations/02-resilient/src/langchain-azure-resilient-invocations/Dockerfile +++ b/samples/python/hosted-agents/langgraph/invocations/02-resilient/src/langchain-azure-resilient-invocations/Dockerfile @@ -7,23 +7,16 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile Python bytecode at build time so cold starts don't pay for it. +# uv compiles site-packages, not the stdlib or application code. Slim base +# images ship little precompiled stdlib bytecode, so those imports may still +# compile on first use. +# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled +# .pyc files still benefit images that set it. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/langgraph/invocations/03-run/src/langgraph-run-invocations/Dockerfile b/samples/python/hosted-agents/langgraph/invocations/03-run/src/langgraph-run-invocations/Dockerfile index 822d893be..3913a7554 100644 --- a/samples/python/hosted-agents/langgraph/invocations/03-run/src/langgraph-run-invocations/Dockerfile +++ b/samples/python/hosted-agents/langgraph/invocations/03-run/src/langgraph-run-invocations/Dockerfile @@ -7,23 +7,16 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile Python bytecode at build time so cold starts don't pay for it. +# uv compiles site-packages, not the stdlib or application code. Slim base +# images ship little precompiled stdlib bytecode, so those imports may still +# compile on first use. +# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled +# .pyc files still benefit images that set it. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "invocations"] diff --git a/samples/python/hosted-agents/langgraph/responses/08-observability/src/langgraph-observability-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/08-observability/src/langgraph-observability-responses/Dockerfile index 3bec5facb..fb7029a1c 100644 --- a/samples/python/hosted-agents/langgraph/responses/08-observability/src/langgraph-observability-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/08-observability/src/langgraph-observability-responses/Dockerfile @@ -7,23 +7,16 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile Python bytecode at build time so cold starts don't pay for it. +# uv compiles site-packages, not the stdlib or application code. Slim base +# images ship little precompiled stdlib bytecode, so those imports may still +# compile on first use. +# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled +# .pyc files still benefit images that set it. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "responses"] diff --git a/samples/python/hosted-agents/langgraph/responses/09-resilient/src/langchain-azure-resilient-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/09-resilient/src/langchain-azure-resilient-responses/Dockerfile index 8f8150725..42ba1d338 100644 --- a/samples/python/hosted-agents/langgraph/responses/09-resilient/src/langchain-azure-resilient-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/09-resilient/src/langchain-azure-resilient-responses/Dockerfile @@ -7,23 +7,16 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile Python bytecode at build time so cold starts don't pay for it. +# uv compiles site-packages, not the stdlib or application code. Slim base +# images ship little precompiled stdlib bytecode, so those imports may still +# compile on first use. +# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled +# .pyc files still benefit images that set it. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "responses", "--option", "resilient_background=true", "--option", "steerable_conversations=true"] diff --git a/samples/python/hosted-agents/langgraph/responses/10-run/src/langgraph-run-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/10-run/src/langgraph-run-responses/Dockerfile index 3bec5facb..fb7029a1c 100644 --- a/samples/python/hosted-agents/langgraph/responses/10-run/src/langgraph-run-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/10-run/src/langgraph-run-responses/Dockerfile @@ -7,23 +7,16 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile Python bytecode at build time so cold starts don't pay for it. +# uv compiles site-packages, not the stdlib or application code. Slim base +# images ship little precompiled stdlib bytecode, so those imports may still +# compile on first use. +# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled +# .pyc files still benefit images that set it. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "responses"] diff --git a/samples/python/hosted-agents/langgraph/responses/11-deep-agents/src/langgraph-deep-agents/Dockerfile b/samples/python/hosted-agents/langgraph/responses/11-deep-agents/src/langgraph-deep-agents/Dockerfile index 1212c9d2b..561d222be 100644 --- a/samples/python/hosted-agents/langgraph/responses/11-deep-agents/src/langgraph-deep-agents/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/11-deep-agents/src/langgraph-deep-agents/Dockerfile @@ -7,23 +7,16 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile Python bytecode at build time so cold starts don't pay for it. +# uv compiles site-packages, not the stdlib or application code. Slim base +# images ship little precompiled stdlib bytecode, so those imports may still +# compile on first use. +# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled +# .pyc files still benefit images that set it. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/langgraph/responses/13-custom-store/src/custom-store/Dockerfile b/samples/python/hosted-agents/langgraph/responses/13-custom-store/src/custom-store/Dockerfile index 1212c9d2b..561d222be 100644 --- a/samples/python/hosted-agents/langgraph/responses/13-custom-store/src/custom-store/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/13-custom-store/src/custom-store/Dockerfile @@ -7,23 +7,16 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile Python bytecode at build time so cold starts don't pay for it. +# uv compiles site-packages, not the stdlib or application code. Slim base +# images ship little precompiled stdlib bytecode, so those imports may still +# compile on first use. +# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled +# .pyc files still benefit images that set it. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/langgraph/responses/14-middleware/src/langgraph-middleware/Dockerfile b/samples/python/hosted-agents/langgraph/responses/14-middleware/src/langgraph-middleware/Dockerfile index 1212c9d2b..561d222be 100644 --- a/samples/python/hosted-agents/langgraph/responses/14-middleware/src/langgraph-middleware/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/14-middleware/src/langgraph-middleware/Dockerfile @@ -7,23 +7,16 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile Python bytecode at build time so cold starts don't pay for it. +# uv compiles site-packages, not the stdlib or application code. Slim base +# images ship little precompiled stdlib bytecode, so those imports may still +# compile on first use. +# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled +# .pyc files still benefit images that set it. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/langgraph/responses/15-branching/src/langgraph-branching/Dockerfile b/samples/python/hosted-agents/langgraph/responses/15-branching/src/langgraph-branching/Dockerfile index 0ddc818e8..bc3c47033 100644 --- a/samples/python/hosted-agents/langgraph/responses/15-branching/src/langgraph-branching/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/15-branching/src/langgraph-branching/Dockerfile @@ -7,7 +7,13 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile Python bytecode at build time so cold starts don't pay for it. +# uv compiles site-packages, not the stdlib or application code. Slim base +# images ship little precompiled stdlib bytecode, so those imports may still +# compile on first use. +# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled +# .pyc files still benefit images that set it. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . @@ -15,17 +21,4 @@ ENV PATH="/app/user_agent/.venv/bin:$PATH" EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["python", "main.py"] From d21cbf7f7eb95536c74837251e66ab21a6416b67 Mon Sep 17 00:00:00 2001 From: Wenxing Zhu Date: Fri, 13 Nov 2026 18:04:04 +0800 Subject: [PATCH 2/2] Use uv bytecode compilation across all sample Dockerfiles --- .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../src/bat-python-maf/Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 10 ++++----- .../Dockerfile | 9 ++++---- .../Dockerfile | 9 ++++---- .../Dockerfile | 19 +++++------------ .../Dockerfile | 9 ++++---- .../Dockerfile | 19 +++++------------ .../ag-ui/src/ag-ui-invocations/Dockerfile | 19 +++++------------ .../claude-agent-sdk-invocations/Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../src/github-copilot-invocations/Dockerfile | 19 +++++------------ .../hello-world-python-invocations/Dockerfile | 19 +++++------------ .../human-in-the-loop-invocations/Dockerfile | 19 +++++------------ .../src/langgraph-chat-invocations/Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../src/resilient-approval-gate/Dockerfile | 19 +++++------------ .../src/resilient-research/Dockerfile | 17 +++++---------- .../src/toolbox-python-invocations/Dockerfile | 19 +++++------------ .../src/duplex-live-agent/Dockerfile | 19 +++++------------ .../hello-world/src/hello-world/Dockerfile | 19 +++++------------ .../src/livekit-server/Dockerfile | 19 +++++------------ .../src/pipecat-ws-webrtc/Dockerfile | 21 +++++-------------- .../src/pipecat-ws-server/Dockerfile | 21 +++++-------------- .../src/background-agent-responses/Dockerfile | 19 +++++------------ .../src/toolbox-python-responses/Dockerfile | 19 +++++------------ .../src/bat-python-byo/Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../hello-world-python-responses/Dockerfile | 19 +++++------------ .../src/langgraph-chat-responses/Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../src/toolbox-langgraph/Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../openai-agents-sdk-invocations/Dockerfile | 19 +++++------------ .../src/openai-computer-tool/Dockerfile | 10 ++++----- .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../src/resilient-steering/Dockerfile | 17 +++++---------- .../src/resilient-streaming/Dockerfile | 17 +++++---------- .../Dockerfile | 19 +++++------------ .../uv-pyproject-python-responses/Dockerfile | 21 +++++-------------- .../Dockerfile | 19 +++++------------ .../Dockerfile | 11 +++++----- .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../a2a/a2a-caller/src/concierge/Dockerfile | 19 +++++------------ .../a2a-executor/src/math-expert/Dockerfile | 19 +++++------------ .../src/langgraph-chat-invocations/Dockerfile | 19 +++++------------ .../Dockerfile | 10 ++++----- .../src/langgraph-run-invocations/Dockerfile | 10 ++++----- .../Dockerfile | 9 ++++---- .../src/langgraph-chat-responses/Dockerfile | 19 +++++------------ .../src/toolbox-langgraph/Dockerfile | 19 +++++------------ .../Dockerfile | 12 +++++------ .../langgraph-workflows-responses/Dockerfile | 19 +++++------------ .../src/langgraph-files-responses/Dockerfile | 19 +++++------------ .../Dockerfile | 19 +++++------------ .../Dockerfile | 10 ++++----- .../Dockerfile | 10 ++++----- .../src/langgraph-run-responses/Dockerfile | 10 ++++----- .../src/langgraph-deep-agents/Dockerfile | 10 ++++----- .../Dockerfile | 9 ++++---- .../src/custom-store/Dockerfile | 10 ++++----- .../src/langgraph-middleware/Dockerfile | 10 ++++----- .../src/langgraph-branching/Dockerfile | 10 ++++----- 90 files changed, 440 insertions(+), 1106 deletions(-) diff --git a/samples/python/hosted-agents/agent-framework/a2a/01-delegation/caller/src/agent-framework-a2a-caller-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/a2a/01-delegation/caller/src/agent-framework-a2a-caller-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/a2a/01-delegation/caller/src/agent-framework-a2a-caller-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/a2a/01-delegation/caller/src/agent-framework-a2a-caller-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/a2a/01-delegation/executor/src/agent-framework-a2a-executor-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/a2a/01-delegation/executor/src/agent-framework-a2a-executor-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/a2a/01-delegation/executor/src/agent-framework-a2a-executor-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/a2a/01-delegation/executor/src/agent-framework-a2a-executor-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/invocations/01-basic/src/agent-framework-agent-basic-invocations/Dockerfile b/samples/python/hosted-agents/agent-framework/invocations/01-basic/src/agent-framework-agent-basic-invocations/Dockerfile index de2f4a042..afffddc5f 100644 --- a/samples/python/hosted-agents/agent-framework/invocations/01-basic/src/agent-framework-agent-basic-invocations/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/invocations/01-basic/src/agent-framework-agent-basic-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/agent-framework/invocations/02-content-safety-guardrail/src/agent-framework-content-safety-guardrail-invocations/Dockerfile b/samples/python/hosted-agents/agent-framework/invocations/02-content-safety-guardrail/src/agent-framework-content-safety-guardrail-invocations/Dockerfile index de2f4a042..afffddc5f 100644 --- a/samples/python/hosted-agents/agent-framework/invocations/02-content-safety-guardrail/src/agent-framework-content-safety-guardrail-invocations/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/invocations/02-content-safety-guardrail/src/agent-framework-content-safety-guardrail-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/agent-framework/responses/01-basic/src/agent-framework-agent-basic-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/01-basic/src/agent-framework-agent-basic-responses/Dockerfile index de2f4a042..afffddc5f 100644 --- a/samples/python/hosted-agents/agent-framework/responses/01-basic/src/agent-framework-agent-basic-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/01-basic/src/agent-framework-agent-basic-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/agent-framework/responses/02-tools/src/agent-framework-agent-with-local-tools-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/02-tools/src/agent-framework-agent-with-local-tools-responses/Dockerfile index de2f4a042..afffddc5f 100644 --- a/samples/python/hosted-agents/agent-framework/responses/02-tools/src/agent-framework-agent-with-local-tools-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/02-tools/src/agent-framework-agent-with-local-tools-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/agent-framework/responses/04-foundry-toolbox/src/agent-framework-agent-with-foundry-toolbox-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/04-foundry-toolbox/src/agent-framework-agent-with-foundry-toolbox-responses/Dockerfile index de2f4a042..afffddc5f 100644 --- a/samples/python/hosted-agents/agent-framework/responses/04-foundry-toolbox/src/agent-framework-agent-with-foundry-toolbox-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/04-foundry-toolbox/src/agent-framework-agent-with-foundry-toolbox-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/agent-framework/responses/05-workflows/src/agent-framework-workflows-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/05-workflows/src/agent-framework-workflows-responses/Dockerfile index de2f4a042..afffddc5f 100644 --- a/samples/python/hosted-agents/agent-framework/responses/05-workflows/src/agent-framework-workflows-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/05-workflows/src/agent-framework-workflows-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/agent-framework/responses/06-files/src/agent-framework-agent-files-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/06-files/src/agent-framework-agent-files-responses/Dockerfile index de2f4a042..afffddc5f 100644 --- a/samples/python/hosted-agents/agent-framework/responses/06-files/src/agent-framework-agent-files-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/06-files/src/agent-framework-agent-files-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/agent-framework/responses/07-skills/src/agent-framework-agent-with-skills-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/07-skills/src/agent-framework-agent-with-skills-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/07-skills/src/agent-framework-agent-with-skills-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/07-skills/src/agent-framework-agent-with-skills-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/07-teams-activity/src/agent-framework-agent-teams-activity/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/07-teams-activity/src/agent-framework-agent-teams-activity/Dockerfile index de2f4a042..afffddc5f 100644 --- a/samples/python/hosted-agents/agent-framework/responses/07-teams-activity/src/agent-framework-agent-teams-activity/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/07-teams-activity/src/agent-framework-agent-teams-activity/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/agent-framework/responses/08-observability/src/agent-framework-agent-observability-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/08-observability/src/agent-framework-agent-observability-responses/Dockerfile index de2f4a042..afffddc5f 100644 --- a/samples/python/hosted-agents/agent-framework/responses/08-observability/src/agent-framework-agent-observability-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/08-observability/src/agent-framework-agent-observability-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/agent-framework/responses/09-declarative-customer-support/src/agent-framework-declarative-customer-support-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/09-declarative-customer-support/src/agent-framework-declarative-customer-support-responses/Dockerfile index 6d1663c93..131b219b9 100644 --- a/samples/python/hosted-agents/agent-framework/responses/09-declarative-customer-support/src/agent-framework-declarative-customer-support-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/09-declarative-customer-support/src/agent-framework-declarative-customer-support-responses/Dockerfile @@ -24,23 +24,14 @@ ENV DOTNET_ROOT=/usr/share/dotnet WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/10-downstream-azure/src/agent-framework-agent-downstream-azure-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/10-downstream-azure/src/agent-framework-agent-downstream-azure-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/10-downstream-azure/src/agent-framework-agent-downstream-azure-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/10-downstream-azure/src/agent-framework-agent-downstream-azure-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/11-azure-search-rag/src/agent-framework-agent-azure-search-rag-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/11-azure-search-rag/src/agent-framework-agent-azure-search-rag-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/11-azure-search-rag/src/agent-framework-agent-azure-search-rag-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/11-azure-search-rag/src/agent-framework-agent-azure-search-rag-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/12-foundry-skills/src/agent-framework-agent-foundry-skills-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/12-foundry-skills/src/agent-framework-agent-foundry-skills-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/12-foundry-skills/src/agent-framework-agent-foundry-skills-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/12-foundry-skills/src/agent-framework-agent-foundry-skills-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/13-foundry-memory/src/agent-framework-agent-foundry-memory-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/13-foundry-memory/src/agent-framework-agent-foundry-memory-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/13-foundry-memory/src/agent-framework-agent-foundry-memory-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/13-foundry-memory/src/agent-framework-agent-foundry-memory-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/14-browser-automation-agent/src/bat-python-maf/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/14-browser-automation-agent/src/bat-python-maf/Dockerfile index 4d997daef..2c0f3eef0 100644 --- a/samples/python/hosted-agents/agent-framework/responses/14-browser-automation-agent/src/bat-python-maf/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/14-browser-automation-agent/src/bat-python-maf/Dockerfile @@ -10,23 +10,14 @@ ENV PYTHONUNBUFFERED=1 \ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/15-optimization-travel-approver/src/optimization-travel-approver-python-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/15-optimization-travel-approver/src/optimization-travel-approver-python-responses/Dockerfile index 1f08172db..55f01ff36 100644 --- a/samples/python/hosted-agents/agent-framework/responses/15-optimization-travel-approver/src/optimization-travel-approver-python-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/15-optimization-travel-approver/src/optimization-travel-approver-python-responses/Dockerfile @@ -7,7 +7,11 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . @@ -16,17 +20,4 @@ EXPOSE 8088 # vNext (ADC): Append the egress proxy CA cert to system and Python cert bundles # so that outbound HTTPS (App Insights, Azure services, etc.) works correctly. -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["bash", "-c", "if [ -f /etc/ssl/certs/adc-egress-proxy-ca.crt ]; then cat /etc/ssl/certs/adc-egress-proxy-ca.crt >> /etc/ssl/certs/ca-certificates.crt && cat /etc/ssl/certs/adc-egress-proxy-ca.crt >> $(.venv/bin/python -c 'import certifi; print(certifi.where())'); fi && exec .venv/bin/python main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/16-content-safety-guardrail/src/agent-framework-content-safety-guardrail/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/16-content-safety-guardrail/src/agent-framework-content-safety-guardrail/Dockerfile index de2f4a042..afffddc5f 100644 --- a/samples/python/hosted-agents/agent-framework/responses/16-content-safety-guardrail/src/agent-framework-content-safety-guardrail/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/16-content-safety-guardrail/src/agent-framework-content-safety-guardrail/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/agent-framework/responses/17-foundry-iq-toolbox/src/agent-framework-foundry-iq-knowledge-base-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/17-foundry-iq-toolbox/src/agent-framework-foundry-iq-knowledge-base-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/17-foundry-iq-toolbox/src/agent-framework-foundry-iq-knowledge-base-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/17-foundry-iq-toolbox/src/agent-framework-foundry-iq-knowledge-base-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/18-egress-control/src/agent-framework-egress-control-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/18-egress-control/src/agent-framework-egress-control-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/18-egress-control/src/agent-framework-egress-control-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/18-egress-control/src/agent-framework-egress-control-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/19-harness-research/src/agent-framework-harness-research-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/19-harness-research/src/agent-framework-harness-research-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/19-harness-research/src/agent-framework-harness-research-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/19-harness-research/src/agent-framework-harness-research-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/20-harness-data-processing/src/agent-framework-harness-data-processing-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/20-harness-data-processing/src/agent-framework-harness-data-processing-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/20-harness-data-processing/src/agent-framework-harness-data-processing-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/20-harness-data-processing/src/agent-framework-harness-data-processing-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/21-harness-scaling-capabilities/src/harness-scaling-capabilities-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/21-harness-scaling-capabilities/src/harness-scaling-capabilities-responses/Dockerfile index b30d8d510..5a3a6fd72 100644 --- a/samples/python/hosted-agents/agent-framework/responses/21-harness-scaling-capabilities/src/harness-scaling-capabilities-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/21-harness-scaling-capabilities/src/harness-scaling-capabilities-responses/Dockerfile @@ -8,23 +8,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app COPY pyproject.toml uv.lock ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= /app/.venv/bin/python -m compileall -q $(/app/.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= /app/.venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/22-foundry-toolbox-mcp-skills/src/agent-framework-agent-foundry-toolbox-mcp-skills-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/22-foundry-toolbox-mcp-skills/src/agent-framework-agent-foundry-toolbox-mcp-skills-responses/Dockerfile index 561d222be..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/22-foundry-toolbox-mcp-skills/src/agent-framework-agent-foundry-toolbox-mcp-skills-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/22-foundry-toolbox-mcp-skills/src/agent-framework-agent-foundry-toolbox-mcp-skills-responses/Dockerfile @@ -7,12 +7,10 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -# Precompile Python bytecode at build time so cold starts don't pay for it. -# uv compiles site-packages, not the stdlib or application code. Slim base -# images ship little precompiled stdlib bytecode, so those imports may still -# compile on first use. -# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled -# .pyc files still benefit images that set it. +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . diff --git a/samples/python/hosted-agents/agent-framework/responses/23-resilient-workflow/src/agent-framework-resilient-workflow-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/23-resilient-workflow/src/agent-framework-resilient-workflow-responses/Dockerfile index 7c4973026..5a3a6fd72 100644 --- a/samples/python/hosted-agents/agent-framework/responses/23-resilient-workflow/src/agent-framework-resilient-workflow-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/23-resilient-workflow/src/agent-framework-resilient-workflow-responses/Dockerfile @@ -8,13 +8,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app COPY pyproject.toml uv.lock ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -RUN PYTHONDONTWRITEBYTECODE= /app/.venv/bin/python -m compileall -q $(/app/.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= /app/.venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/24-steering/src/agent-framework-steering-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/24-steering/src/agent-framework-steering-responses/Dockerfile index 7c4973026..5a3a6fd72 100644 --- a/samples/python/hosted-agents/agent-framework/responses/24-steering/src/agent-framework-steering-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/24-steering/src/agent-framework-steering-responses/Dockerfile @@ -8,13 +8,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app COPY pyproject.toml uv.lock ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -RUN PYTHONDONTWRITEBYTECODE= /app/.venv/bin/python -m compileall -q $(/app/.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= /app/.venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/25-claude-foundry-toolbox/src/claude-foundry-toolbox-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/25-claude-foundry-toolbox/src/claude-foundry-toolbox-responses/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/agent-framework/responses/25-claude-foundry-toolbox/src/claude-foundry-toolbox-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/25-claude-foundry-toolbox/src/claude-foundry-toolbox-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/agent-framework/responses/26-custom-store/src/agent-framework-agent-custom-store-responses/Dockerfile b/samples/python/hosted-agents/agent-framework/responses/26-custom-store/src/agent-framework-agent-custom-store-responses/Dockerfile index 1658d7cc4..0aff81cc0 100644 --- a/samples/python/hosted-agents/agent-framework/responses/26-custom-store/src/agent-framework-agent-custom-store-responses/Dockerfile +++ b/samples/python/hosted-agents/agent-framework/responses/26-custom-store/src/agent-framework-agent-custom-store-responses/Dockerfile @@ -6,13 +6,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app COPY pyproject.toml uv.lock ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -RUN PYTHONDONTWRITEBYTECODE= /app/.venv/bin/python -m compileall -q $(/app/.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= /app/.venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/samples/python/hosted-agents/bring-your-own/conversation_engine/foreground_background/src/foreground-background-agents-voicelive/Dockerfile b/samples/python/hosted-agents/bring-your-own/conversation_engine/foreground_background/src/foreground-background-agents-voicelive/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/bring-your-own/conversation_engine/foreground_background/src/foreground-background-agents-voicelive/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/conversation_engine/foreground_background/src/foreground-background-agents-voicelive/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/ag-ui/src/ag-ui-invocations/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/ag-ui/src/ag-ui-invocations/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/ag-ui/src/ag-ui-invocations/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/ag-ui/src/ag-ui-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/claude-agent-sdk/src/claude-agent-sdk-invocations/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/claude-agent-sdk/src/claude-agent-sdk-invocations/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/claude-agent-sdk/src/claude-agent-sdk-invocations/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/claude-agent-sdk/src/claude-agent-sdk-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/diagnostic-agent/src/diagnostic-agent-python-invocations/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/diagnostic-agent/src/diagnostic-agent-python-invocations/Dockerfile index 253a72ba9..2d1d644f9 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/diagnostic-agent/src/diagnostic-agent-python-invocations/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/diagnostic-agent/src/diagnostic-agent-python-invocations/Dockerfile @@ -28,23 +28,14 @@ RUN apt-get update \ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/event-grid-trigger/src/event-grid-trigger-python-invocations/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/event-grid-trigger/src/event-grid-trigger-python-invocations/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/event-grid-trigger/src/event-grid-trigger-python-invocations/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/event-grid-trigger/src/event-grid-trigger-python-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/github-copilot/src/github-copilot-invocations/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/github-copilot/src/github-copilot-invocations/Dockerfile index 0b0f4c812..c68ea0934 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/github-copilot/src/github-copilot-invocations/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/github-copilot/src/github-copilot-invocations/Dockerfile @@ -7,7 +7,11 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . @@ -24,17 +28,4 @@ ENV COPILOT_CLI_PATH=/usr/local/bin/copilot EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/hello-world/src/hello-world-python-invocations/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/hello-world/src/hello-world-python-invocations/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/hello-world/src/hello-world-python-invocations/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/hello-world/src/hello-world-python-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/human-in-the-loop/src/human-in-the-loop-invocations/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/human-in-the-loop/src/human-in-the-loop-invocations/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/human-in-the-loop/src/human-in-the-loop-invocations/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/human-in-the-loop/src/human-in-the-loop-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/langgraph-chat/src/langgraph-chat-invocations/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/langgraph-chat/src/langgraph-chat-invocations/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/langgraph-chat/src/langgraph-chat-invocations/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/langgraph-chat/src/langgraph-chat-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/notetaking-agent/src/notetaking-agent-invocations-python/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/notetaking-agent/src/notetaking-agent-invocations-python/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/notetaking-agent/src/notetaking-agent-invocations-python/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/notetaking-agent/src/notetaking-agent-invocations-python/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/resilient-approval-gate/src/resilient-approval-gate/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/resilient-approval-gate/src/resilient-approval-gate/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/resilient-approval-gate/src/resilient-approval-gate/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/resilient-approval-gate/src/resilient-approval-gate/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/resilient-research/src/resilient-research/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/resilient-research/src/resilient-research/Dockerfile index 9fd46f25f..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/resilient-research/src/resilient-research/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/resilient-research/src/resilient-research/Dockerfile @@ -7,21 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled, so -# without this every new container recompiles hundreds of stdlib modules on -# first import. Dependencies are best-effort (`|| true`) so a stray unparsable -# file vendored by a third-party package can't fail the build; application code -# is compiled strictly so a syntax error surfaces at build time. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks bytecode -# *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations/toolbox/src/toolbox-python-invocations/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations/toolbox/src/toolbox-python-invocations/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations/toolbox/src/toolbox-python-invocations/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations/toolbox/src/toolbox-python-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations_ws/duplex-live-agent/src/duplex-live-agent/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations_ws/duplex-live-agent/src/duplex-live-agent/Dockerfile index 1867ae234..af885c749 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations_ws/duplex-live-agent/src/duplex-live-agent/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations_ws/duplex-live-agent/src/duplex-live-agent/Dockerfile @@ -11,23 +11,14 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . ./ EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations_ws/hello-world/src/hello-world/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations_ws/hello-world/src/hello-world/Dockerfile index d8d0dfdc1..d108f28dd 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations_ws/hello-world/src/hello-world/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations_ws/hello-world/src/hello-world/Dockerfile @@ -11,23 +11,14 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY main.py ./ EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations_ws/livekit-server/src/livekit-server/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations_ws/livekit-server/src/livekit-server/Dockerfile index 263414f88..2d018c80a 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations_ws/livekit-server/src/livekit-server/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations_ws/livekit-server/src/livekit-server/Dockerfile @@ -14,7 +14,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc g++ && rm -rf /var/lib/apt/lists/* COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project \ +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode \ && (find /app/.venv/lib/python3.12/site-packages \ \( -type d -name 'tests' \ -o -type d -name 'test' \) \ @@ -32,17 +36,4 @@ EXPOSE 8088 # command runs both the FastAPI signaling endpoint and the LiveKit # agent worker. -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/.venv/bin/python", "server.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-webrtc/src/pipecat-ws-webrtc/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-webrtc/src/pipecat-ws-webrtc/Dockerfile index 34bebc2e5..71661bdf4 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-webrtc/src/pipecat-ws-webrtc/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-webrtc/src/pipecat-ws-webrtc/Dockerfile @@ -7,8 +7,6 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app -# Keep bytecode out of the image layer that pip writes, then precompile -# deliberately below once the app code is in place. ENV PYTHONDONTWRITEBYTECODE=1 # Foundry hosted agents expose port 8088 by convention; force the @@ -17,7 +15,11 @@ ENV PORT=8088 # Install Python dependencies and strip unnecessary artifacts in the same layer. COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project \ +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode \ && (find /app/.venv/lib/python3.12/site-packages \ \( -type d -name 'tests' \ -o -type d -name 'test' \) \ @@ -36,17 +38,4 @@ COPY server.py \ EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/.venv/bin/python", "server.py"] diff --git a/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-ws-server/src/pipecat-ws-server/Dockerfile b/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-ws-server/src/pipecat-ws-server/Dockerfile index 200097962..42197b867 100644 --- a/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-ws-server/src/pipecat-ws-server/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-ws-server/src/pipecat-ws-server/Dockerfile @@ -7,13 +7,15 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app -# Keep bytecode out of the image layer that pip writes, then precompile -# deliberately below once the app code is in place. ENV PYTHONDONTWRITEBYTECODE=1 # Install Python dependencies and strip unnecessary artifacts in the same layer. COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project \ +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode \ && (find /app/.venv/lib/python3.12/site-packages \ \( -type d -name 'tests' \ -o -type d -name 'test' \) \ @@ -24,17 +26,4 @@ COPY server.py bot_websocket_server.py azure_fast_transcription_stt.py azure_tts EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/.venv/bin/python", "server.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/background-agent/src/background-agent-responses/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/background-agent/src/background-agent-responses/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/background-agent/src/background-agent-responses/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/background-agent/src/background-agent-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/bring-your-own-toolbox/src/toolbox-python-responses/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/bring-your-own-toolbox/src/toolbox-python-responses/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/bring-your-own-toolbox/src/toolbox-python-responses/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/bring-your-own-toolbox/src/toolbox-python-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/browser-automation/src/bat-python-byo/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/browser-automation/src/bat-python-byo/Dockerfile index 1d2c7b9b3..de8794be8 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/browser-automation/src/bat-python-byo/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/browser-automation/src/bat-python-byo/Dockerfile @@ -14,7 +14,11 @@ WORKDIR /app # Install Python dependencies WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode # Copy source COPY main.py ./ @@ -23,17 +27,4 @@ COPY skills/ ./skills/ EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/env-vars-agent/src/env-vars-agent-responses-python/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/env-vars-agent/src/env-vars-agent-responses-python/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/env-vars-agent/src/env-vars-agent-responses-python/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/env-vars-agent/src/env-vars-agent-responses-python/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/hello-world/src/hello-world-python-responses/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/hello-world/src/hello-world-python-responses/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/hello-world/src/hello-world-python-responses/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/hello-world/src/hello-world-python-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/langgraph-chat/src/langgraph-chat-responses/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/langgraph-chat/src/langgraph-chat-responses/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/langgraph-chat/src/langgraph-chat-responses/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/langgraph-chat/src/langgraph-chat-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox-user-identity/src/toolbox-langgraph-user-identity/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox-user-identity/src/toolbox-langgraph-user-identity/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox-user-identity/src/toolbox-langgraph-user-identity/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox-user-identity/src/toolbox-langgraph-user-identity/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox/src/toolbox-langgraph/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox/src/toolbox-langgraph/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox/src/toolbox-langgraph/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox/src/toolbox-langgraph/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/notetaking-agent/src/notetaking-agent-responses-python/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/notetaking-agent/src/notetaking-agent-responses-python/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/notetaking-agent/src/notetaking-agent-responses-python/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/notetaking-agent/src/notetaking-agent-responses-python/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/openai-agents-sdk/src/openai-agents-sdk-invocations/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/openai-agents-sdk/src/openai-agents-sdk-invocations/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/openai-agents-sdk/src/openai-agents-sdk-invocations/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/openai-agents-sdk/src/openai-agents-sdk-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/openai-computer-tool/src/openai-computer-tool/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/openai-computer-tool/src/openai-computer-tool/Dockerfile index a4ed35e1b..48e308cce 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/openai-computer-tool/src/openai-computer-tool/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/openai-computer-tool/src/openai-computer-tool/Dockerfile @@ -27,7 +27,11 @@ WORKDIR /app/user_agent # Install Python dependencies COPY pyproject.toml uv.lock ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode # Copy source COPY main.py ./ @@ -36,8 +40,4 @@ COPY utils/ ./utils/ EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["sh", "-c", "if ! pgrep -x Xvfb >/dev/null 2>&1; then Xvfb \"${DISPLAY:-:99}\" -screen 0 1280x800x24 -ac +extension GLX +render -noreset >/tmp/xvfb.log 2>&1 & sleep 1; fi; touch \"${XAUTHORITY:-/tmp/.Xauthority}\" 2>/dev/null || true; exec /app/user_agent/.venv/bin/python /app/user_agent/main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/optimization-customer-support/src/optimization-customer-support-python-responses/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/optimization-customer-support/src/optimization-customer-support-python-responses/Dockerfile index 5c2ed8df4..336d62e32 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/optimization-customer-support/src/optimization-customer-support-python-responses/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/optimization-customer-support/src/optimization-customer-support-python-responses/Dockerfile @@ -7,7 +7,11 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . @@ -16,19 +20,6 @@ EXPOSE 8088 # vNext (ADC): Append the egress proxy CA cert to system and Python cert bundles # so that outbound HTTPS (App Insights, Azure services, etc.) works correctly. -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD bash -c '\ if [ -f /etc/ssl/certs/adc-egress-proxy-ca.crt ]; then \ cat /etc/ssl/certs/adc-egress-proxy-ca.crt >> /etc/ssl/certs/ca-certificates.crt && \ diff --git a/samples/python/hosted-agents/bring-your-own/responses/optimization-hello-world/src/optimization-hello-world-python-responses/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/optimization-hello-world/src/optimization-hello-world-python-responses/Dockerfile index 5c2ed8df4..336d62e32 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/optimization-hello-world/src/optimization-hello-world-python-responses/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/optimization-hello-world/src/optimization-hello-world-python-responses/Dockerfile @@ -7,7 +7,11 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . @@ -16,19 +20,6 @@ EXPOSE 8088 # vNext (ADC): Append the egress proxy CA cert to system and Python cert bundles # so that outbound HTTPS (App Insights, Azure services, etc.) works correctly. -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD bash -c '\ if [ -f /etc/ssl/certs/adc-egress-proxy-ca.crt ]; then \ cat /etc/ssl/certs/adc-egress-proxy-ca.crt >> /etc/ssl/certs/ca-certificates.crt && \ diff --git a/samples/python/hosted-agents/bring-your-own/responses/resilient-steering/src/resilient-steering/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/resilient-steering/src/resilient-steering/Dockerfile index 9fd46f25f..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/resilient-steering/src/resilient-steering/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/resilient-steering/src/resilient-steering/Dockerfile @@ -7,21 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled, so -# without this every new container recompiles hundreds of stdlib modules on -# first import. Dependencies are best-effort (`|| true`) so a stray unparsable -# file vendored by a third-party package can't fail the build; application code -# is compiled strictly so a syntax error surfaces at build time. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks bytecode -# *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/resilient-streaming/src/resilient-streaming/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/resilient-streaming/src/resilient-streaming/Dockerfile index 9fd46f25f..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/resilient-streaming/src/resilient-streaming/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/resilient-streaming/src/resilient-streaming/Dockerfile @@ -7,21 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled, so -# without this every new container recompiles hundreds of stdlib modules on -# first import. Dependencies are best-effort (`|| true`) so a stray unparsable -# file vendored by a third-party package can't fail the build; application code -# is compiled strictly so a syntax error surfaces at build time. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks bytecode -# *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/session-multiplexing/src/hello-world-session-multiplexing-python-responses/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/session-multiplexing/src/hello-world-session-multiplexing-python-responses/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/session-multiplexing/src/hello-world-session-multiplexing-python-responses/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/session-multiplexing/src/hello-world-session-multiplexing-python-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/responses/uv-pyproject/src/uv-pyproject-python-responses/Dockerfile b/samples/python/hosted-agents/bring-your-own/responses/uv-pyproject/src/uv-pyproject-python-responses/Dockerfile index 67319a675..5e8f85848 100644 --- a/samples/python/hosted-agents/bring-your-own/responses/uv-pyproject/src/uv-pyproject-python-responses/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/responses/uv-pyproject/src/uv-pyproject-python-responses/Dockerfile @@ -7,25 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -# The venv interpreter is used so its site-packages are covered; the venv is -# excluded from the strict application pass. -RUN PYTHONDONTWRITEBYTECODE= /app/user_agent/.venv/bin/python -m compileall -q $(/app/user_agent/.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= /app/user_agent/.venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/voicelive/foreground-background-agents-responses-voicelive/src/foreground-background-agents-voicelive/Dockerfile b/samples/python/hosted-agents/bring-your-own/voicelive/foreground-background-agents-responses-voicelive/src/foreground-background-agents-voicelive/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/voicelive/foreground-background-agents-responses-voicelive/src/foreground-background-agents-voicelive/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/voicelive/foreground-background-agents-responses-voicelive/src/foreground-background-agents-voicelive/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/voicelive/github-copilot-responses-voicelive/src/github-copilot-responses-voicelive/Dockerfile b/samples/python/hosted-agents/bring-your-own/voicelive/github-copilot-responses-voicelive/src/github-copilot-responses-voicelive/Dockerfile index 33a1d65f0..cba6718b4 100644 --- a/samples/python/hosted-agents/bring-your-own/voicelive/github-copilot-responses-voicelive/src/github-copilot-responses-voicelive/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/voicelive/github-copilot-responses-voicelive/src/github-copilot-responses-voicelive/Dockerfile @@ -7,7 +7,11 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode # Resolve the SDK's pinned CLI runtime at build time instead of on the first # invocation, when the container filesystem may be read-only. @@ -26,9 +30,4 @@ COPY . . EXPOSE 8088 -# Precompile dependencies best-effort, but fail the build for invalid -# application Python. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/voicelive/handoff-langgraph-responses-voicelive/src/handoff-langgraph-responses-voicelive/Dockerfile b/samples/python/hosted-agents/bring-your-own/voicelive/handoff-langgraph-responses-voicelive/src/handoff-langgraph-responses-voicelive/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/voicelive/handoff-langgraph-responses-voicelive/src/handoff-langgraph-responses-voicelive/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/voicelive/handoff-langgraph-responses-voicelive/src/handoff-langgraph-responses-voicelive/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/voicelive/hello-world-invocations-voicelive/src/hello-world-python-invocations-voicelive/Dockerfile b/samples/python/hosted-agents/bring-your-own/voicelive/hello-world-invocations-voicelive/src/hello-world-python-invocations-voicelive/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/voicelive/hello-world-invocations-voicelive/src/hello-world-python-invocations-voicelive/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/voicelive/hello-world-invocations-voicelive/src/hello-world-python-invocations-voicelive/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/bring-your-own/voicelive/hotel-booking-invocations-voicelive/src/hotel-booking-python-invocations-voicelive/Dockerfile b/samples/python/hosted-agents/bring-your-own/voicelive/hotel-booking-invocations-voicelive/src/hotel-booking-python-invocations-voicelive/Dockerfile index 13c1a8dfc..d5274cdde 100644 --- a/samples/python/hosted-agents/bring-your-own/voicelive/hotel-booking-invocations-voicelive/src/hotel-booking-python-invocations-voicelive/Dockerfile +++ b/samples/python/hosted-agents/bring-your-own/voicelive/hotel-booking-invocations-voicelive/src/hotel-booking-python-invocations-voicelive/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/langgraph/a2a/a2a-caller/src/concierge/Dockerfile b/samples/python/hosted-agents/langgraph/a2a/a2a-caller/src/concierge/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/langgraph/a2a/a2a-caller/src/concierge/Dockerfile +++ b/samples/python/hosted-agents/langgraph/a2a/a2a-caller/src/concierge/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/langgraph/a2a/a2a-executor/src/math-expert/Dockerfile b/samples/python/hosted-agents/langgraph/a2a/a2a-executor/src/math-expert/Dockerfile index 1212c9d2b..5e8f85848 100644 --- a/samples/python/hosted-agents/langgraph/a2a/a2a-executor/src/math-expert/Dockerfile +++ b/samples/python/hosted-agents/langgraph/a2a/a2a-executor/src/math-expert/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/langgraph/invocations/01-langgraph-chat/src/langgraph-chat-invocations/Dockerfile b/samples/python/hosted-agents/langgraph/invocations/01-langgraph-chat/src/langgraph-chat-invocations/Dockerfile index 822d893be..8811ba343 100644 --- a/samples/python/hosted-agents/langgraph/invocations/01-langgraph-chat/src/langgraph-chat-invocations/Dockerfile +++ b/samples/python/hosted-agents/langgraph/invocations/01-langgraph-chat/src/langgraph-chat-invocations/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "invocations"] diff --git a/samples/python/hosted-agents/langgraph/invocations/02-resilient/src/langchain-azure-resilient-invocations/Dockerfile b/samples/python/hosted-agents/langgraph/invocations/02-resilient/src/langchain-azure-resilient-invocations/Dockerfile index 3ba24012c..d5274cdde 100644 --- a/samples/python/hosted-agents/langgraph/invocations/02-resilient/src/langchain-azure-resilient-invocations/Dockerfile +++ b/samples/python/hosted-agents/langgraph/invocations/02-resilient/src/langchain-azure-resilient-invocations/Dockerfile @@ -7,12 +7,10 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -# Precompile Python bytecode at build time so cold starts don't pay for it. -# uv compiles site-packages, not the stdlib or application code. Slim base -# images ship little precompiled stdlib bytecode, so those imports may still -# compile on first use. -# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled -# .pyc files still benefit images that set it. +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . diff --git a/samples/python/hosted-agents/langgraph/invocations/03-run/src/langgraph-run-invocations/Dockerfile b/samples/python/hosted-agents/langgraph/invocations/03-run/src/langgraph-run-invocations/Dockerfile index 3913a7554..8811ba343 100644 --- a/samples/python/hosted-agents/langgraph/invocations/03-run/src/langgraph-run-invocations/Dockerfile +++ b/samples/python/hosted-agents/langgraph/invocations/03-run/src/langgraph-run-invocations/Dockerfile @@ -7,12 +7,10 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -# Precompile Python bytecode at build time so cold starts don't pay for it. -# uv compiles site-packages, not the stdlib or application code. Slim base -# images ship little precompiled stdlib bytecode, so those imports may still -# compile on first use. -# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled -# .pyc files still benefit images that set it. +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . diff --git a/samples/python/hosted-agents/langgraph/invocations/04-custom-host/src/langgraph-custom-host-invocations/Dockerfile b/samples/python/hosted-agents/langgraph/invocations/04-custom-host/src/langgraph-custom-host-invocations/Dockerfile index 0e08aa3b7..d5274cdde 100644 --- a/samples/python/hosted-agents/langgraph/invocations/04-custom-host/src/langgraph-custom-host-invocations/Dockerfile +++ b/samples/python/hosted-agents/langgraph/invocations/04-custom-host/src/langgraph-custom-host-invocations/Dockerfile @@ -7,13 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/langgraph/responses/01-langgraph-chat/src/langgraph-chat-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/01-langgraph-chat/src/langgraph-chat-responses/Dockerfile index 3bec5facb..fce1824b9 100644 --- a/samples/python/hosted-agents/langgraph/responses/01-langgraph-chat/src/langgraph-chat-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/01-langgraph-chat/src/langgraph-chat-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "responses"] diff --git a/samples/python/hosted-agents/langgraph/responses/02-langgraph-toolbox/src/toolbox-langgraph/Dockerfile b/samples/python/hosted-agents/langgraph/responses/02-langgraph-toolbox/src/toolbox-langgraph/Dockerfile index 3bec5facb..fce1824b9 100644 --- a/samples/python/hosted-agents/langgraph/responses/02-langgraph-toolbox/src/toolbox-langgraph/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/02-langgraph-toolbox/src/toolbox-langgraph/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "responses"] diff --git a/samples/python/hosted-agents/langgraph/responses/03-langgraph-toolbox-user-identity/src/toolbox-langgraph-user-identity/Dockerfile b/samples/python/hosted-agents/langgraph/responses/03-langgraph-toolbox-user-identity/src/toolbox-langgraph-user-identity/Dockerfile index 34540dd8d..8a3d6ff27 100644 --- a/samples/python/hosted-agents/langgraph/responses/03-langgraph-toolbox-user-identity/src/toolbox-langgraph-user-identity/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/03-langgraph-toolbox-user-identity/src/toolbox-langgraph-user-identity/Dockerfile @@ -7,16 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# Dependencies are best-effort so vendored files cannot fail the build; -# application code is compiled strictly so syntax errors surface at build time. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "responses"] diff --git a/samples/python/hosted-agents/langgraph/responses/05-workflows/src/langgraph-workflows-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/05-workflows/src/langgraph-workflows-responses/Dockerfile index 3bec5facb..fce1824b9 100644 --- a/samples/python/hosted-agents/langgraph/responses/05-workflows/src/langgraph-workflows-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/05-workflows/src/langgraph-workflows-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "responses"] diff --git a/samples/python/hosted-agents/langgraph/responses/06-files/src/langgraph-files-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/06-files/src/langgraph-files-responses/Dockerfile index 3bec5facb..fce1824b9 100644 --- a/samples/python/hosted-agents/langgraph/responses/06-files/src/langgraph-files-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/06-files/src/langgraph-files-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "responses"] diff --git a/samples/python/hosted-agents/langgraph/responses/07-human-in-the-loop/src/langgraph-human-in-the-loop-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/07-human-in-the-loop/src/langgraph-human-in-the-loop-responses/Dockerfile index 3bec5facb..fce1824b9 100644 --- a/samples/python/hosted-agents/langgraph/responses/07-human-in-the-loop/src/langgraph-human-in-the-loop-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/07-human-in-the-loop/src/langgraph-human-in-the-loop-responses/Dockerfile @@ -7,23 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -# Precompile Python bytecode at build time so cold starts don't pay for it. -# These base images ship almost none of the standard library precompiled -# (~2% of stdlib .py files, on both Debian-slim and Azure Linux), so without -# this every new container recompiles hundreds of stdlib modules on first -# import. Dependencies are best-effort (`|| true`) so a stray unparsable file -# vendored by a third-party package can't fail the build; application code is -# compiled strictly so a syntax error surfaces at build time rather than at -# container start. -# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks -# bytecode *writes*, not *reads*, so images that set it still benefit. -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "-m", "langchain_azure_ai.agents.hosting.run", "--protocol", "responses"] diff --git a/samples/python/hosted-agents/langgraph/responses/08-observability/src/langgraph-observability-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/08-observability/src/langgraph-observability-responses/Dockerfile index fb7029a1c..fce1824b9 100644 --- a/samples/python/hosted-agents/langgraph/responses/08-observability/src/langgraph-observability-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/08-observability/src/langgraph-observability-responses/Dockerfile @@ -7,12 +7,10 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -# Precompile Python bytecode at build time so cold starts don't pay for it. -# uv compiles site-packages, not the stdlib or application code. Slim base -# images ship little precompiled stdlib bytecode, so those imports may still -# compile on first use. -# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled -# .pyc files still benefit images that set it. +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . diff --git a/samples/python/hosted-agents/langgraph/responses/09-resilient/src/langchain-azure-resilient-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/09-resilient/src/langchain-azure-resilient-responses/Dockerfile index 42ba1d338..4f6ac5bae 100644 --- a/samples/python/hosted-agents/langgraph/responses/09-resilient/src/langchain-azure-resilient-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/09-resilient/src/langchain-azure-resilient-responses/Dockerfile @@ -7,12 +7,10 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -# Precompile Python bytecode at build time so cold starts don't pay for it. -# uv compiles site-packages, not the stdlib or application code. Slim base -# images ship little precompiled stdlib bytecode, so those imports may still -# compile on first use. -# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled -# .pyc files still benefit images that set it. +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . diff --git a/samples/python/hosted-agents/langgraph/responses/10-run/src/langgraph-run-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/10-run/src/langgraph-run-responses/Dockerfile index fb7029a1c..fce1824b9 100644 --- a/samples/python/hosted-agents/langgraph/responses/10-run/src/langgraph-run-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/10-run/src/langgraph-run-responses/Dockerfile @@ -7,12 +7,10 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -# Precompile Python bytecode at build time so cold starts don't pay for it. -# uv compiles site-packages, not the stdlib or application code. Slim base -# images ship little precompiled stdlib bytecode, so those imports may still -# compile on first use. -# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled -# .pyc files still benefit images that set it. +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . diff --git a/samples/python/hosted-agents/langgraph/responses/11-deep-agents/src/langgraph-deep-agents/Dockerfile b/samples/python/hosted-agents/langgraph/responses/11-deep-agents/src/langgraph-deep-agents/Dockerfile index 561d222be..5e8f85848 100644 --- a/samples/python/hosted-agents/langgraph/responses/11-deep-agents/src/langgraph-deep-agents/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/11-deep-agents/src/langgraph-deep-agents/Dockerfile @@ -7,12 +7,10 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -# Precompile Python bytecode at build time so cold starts don't pay for it. -# uv compiles site-packages, not the stdlib or application code. Slim base -# images ship little precompiled stdlib bytecode, so those imports may still -# compile on first use. -# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled -# .pyc files still benefit images that set it. +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . diff --git a/samples/python/hosted-agents/langgraph/responses/12-custom-host/src/langgraph-custom-host-responses/Dockerfile b/samples/python/hosted-agents/langgraph/responses/12-custom-host/src/langgraph-custom-host-responses/Dockerfile index 0e08aa3b7..d5274cdde 100644 --- a/samples/python/hosted-agents/langgraph/responses/12-custom-host/src/langgraph-custom-host-responses/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/12-custom-host/src/langgraph-custom-host-responses/Dockerfile @@ -7,13 +7,14 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -RUN uv sync --frozen --no-dev --no-install-project +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. +RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . EXPOSE 8088 -RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \ - PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' . - CMD ["/app/user_agent/.venv/bin/python", "main.py"] diff --git a/samples/python/hosted-agents/langgraph/responses/13-custom-store/src/custom-store/Dockerfile b/samples/python/hosted-agents/langgraph/responses/13-custom-store/src/custom-store/Dockerfile index 561d222be..5e8f85848 100644 --- a/samples/python/hosted-agents/langgraph/responses/13-custom-store/src/custom-store/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/13-custom-store/src/custom-store/Dockerfile @@ -7,12 +7,10 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -# Precompile Python bytecode at build time so cold starts don't pay for it. -# uv compiles site-packages, not the stdlib or application code. Slim base -# images ship little precompiled stdlib bytecode, so those imports may still -# compile on first use. -# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled -# .pyc files still benefit images that set it. +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . diff --git a/samples/python/hosted-agents/langgraph/responses/14-middleware/src/langgraph-middleware/Dockerfile b/samples/python/hosted-agents/langgraph/responses/14-middleware/src/langgraph-middleware/Dockerfile index 561d222be..5e8f85848 100644 --- a/samples/python/hosted-agents/langgraph/responses/14-middleware/src/langgraph-middleware/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/14-middleware/src/langgraph-middleware/Dockerfile @@ -7,12 +7,10 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -# Precompile Python bytecode at build time so cold starts don't pay for it. -# uv compiles site-packages, not the stdlib or application code. Slim base -# images ship little precompiled stdlib bytecode, so those imports may still -# compile on first use. -# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled -# .pyc files still benefit images that set it. +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . . diff --git a/samples/python/hosted-agents/langgraph/responses/15-branching/src/langgraph-branching/Dockerfile b/samples/python/hosted-agents/langgraph/responses/15-branching/src/langgraph-branching/Dockerfile index bc3c47033..762f243c9 100644 --- a/samples/python/hosted-agents/langgraph/responses/15-branching/src/langgraph-branching/Dockerfile +++ b/samples/python/hosted-agents/langgraph/responses/15-branching/src/langgraph-branching/Dockerfile @@ -7,12 +7,10 @@ COPY --from=uv /uv /uvx /bin/ WORKDIR /app/user_agent COPY pyproject.toml uv.lock uv.toml ./ -# Precompile Python bytecode at build time so cold starts don't pay for it. -# uv compiles site-packages, not the stdlib or application code. Slim base -# images ship little precompiled stdlib bytecode, so those imports may still -# compile on first use. -# PYTHONDONTWRITEBYTECODE blocks bytecode writes, not reads, so precompiled -# .pyc files still benefit images that set it. +# Precompile installed dependencies to reduce startup compilation overhead. +# This covers site-packages, not the stdlib or application source outside it. +# PYTHONDONTWRITEBYTECODE disables automatic .pyc writes on import, +# but Python can still read existing valid .pyc files. RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode COPY . .