From f661b57020614a9e6a331e062a85a5ceaa2c4f19 Mon Sep 17 00:00:00 2001 From: Ben Cherry Date: Fri, 1 May 2026 09:50:46 -0700 Subject: [PATCH] Enable Python bytecode compilation in Dockerfile (#68) 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. --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8f6fa30..58d8996 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,11 @@ FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-bookworm-slim AS base # the application crashes without emitting any logs due to buffering. ENV PYTHONUNBUFFERED=1 +# Compile Python source to bytecode (.pyc) during install so the first import +# doesn't pay the compilation cost. This reduces agent cold-start time at the +# expense of a slightly longer build. +ENV UV_COMPILE_BYTECODE=1 + # --- Build stage --- # Install dependencies, build native extensions, and prepare the application FROM base AS build