Skip to content

Commit 83993e2

Browse files
committed
Enable Python bytecode compilation in Dockerfile
Add UV_COMPILE_BYTECODE=1 to compile Python source to bytecode during install. This reduces agent cold-start time at the expense of a slightly longer build. Mirrors livekit/web#4070.
1 parent 1bab7d4 commit 83993e2

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-bookworm-slim AS base
1010
# the application crashes without emitting any logs due to buffering.
1111
ENV PYTHONUNBUFFERED=1
1212

13+
# Compile Python source to bytecode (.pyc) during install so the first import
14+
# doesn't pay the compilation cost. This reduces agent cold-start time at the
15+
# expense of a slightly longer build.
16+
ENV UV_COMPILE_BYTECODE=1
17+
1318
# --- Build stage ---
1419
# Install dependencies, build native extensions, and prepare the application
1520
FROM base AS build

0 commit comments

Comments
 (0)