Skip to content

Commit ddc8787

Browse files
committed
Dockerfile
1 parent 5a7c9c7 commit ddc8787

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed

Dockerfile

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# syntax=docker/dockerfile:1
22

3+
# Use the official UV Python base image with Python 3.11 on Debian Bookworm
4+
# UV is a fast Python package manager that provides better performance than pip
5+
# We use the slim variant to keep the image size smaller while still having essential tools
36
ARG PYTHON_VERSION=3.11
4-
# Fast Python builds using uv on Debian bookworm-slim
57
FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-bookworm-slim AS base
68

7-
ARG UID=10001
8-
9-
# Ensures that logs are captured in realtime
9+
# Keeps Python from buffering stdout and stderr to avoid situations where
10+
# the application crashes without emitting any logs due to buffering.
1011
ENV PYTHONUNBUFFERED=1
1112

12-
# Create unprivileged user
13+
# Create a non-privileged user that the app will run under.
14+
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
15+
ARG UID=10001
1316
RUN adduser \
1417
--disabled-password \
1518
--gecos "" \
@@ -18,26 +21,48 @@ RUN adduser \
1821
--uid "${UID}" \
1922
appuser
2023

21-
# System build deps for common Python wheels
24+
# Install build dependencies required for Python packages with native extensions
25+
# gcc: C compiler needed for building Python packages with C extensions
26+
# python3-dev: Python development headers needed for compilation
27+
# We clean up the apt cache after installation to keep the image size down
2228
RUN apt-get update && apt-get install -y \
2329
gcc \
2430
python3-dev \
2531
&& rm -rf /var/lib/apt/lists/*
2632

33+
# Create a new directory for our application code
34+
# And set it as the working directory
2735
WORKDIR /app
2836

29-
# Dependency install first for better caching
37+
# Copy just the dependency files first, for more efficient layer caching
3038
COPY pyproject.toml uv.lock ./
3139
RUN mkdir -p src
40+
41+
# Install Python dependencies using UV's lock file
42+
# --locked ensures we use exact versions from uv.lock for reproducible builds
43+
# This creates a virtual environment and installs all dependencies
44+
# Ensure your uv.lock file is checked in for consistency across environments
3245
RUN uv sync --locked
3346

34-
# Copy application code
47+
# Copy all remaining pplication files into the container
48+
# This includes source code, configuration files, and dependency specifications
49+
# (Excludes files specified in .dockerignore)
3550
COPY . .
51+
52+
# Change ownership of all app files to the non-privileged user
53+
# This ensures the application can read/write files as needed
3654
RUN chown -R appuser:appuser /app
55+
56+
# Switch to the non-privileged user for all subsequent operations
57+
# This improves security by not running as root
3758
USER appuser
3859

39-
# Pre-download models/assets at build time
60+
# Pre-download any ML models or files the agent needs
61+
# This ensures the container is ready to run immediately without downloading
62+
# dependencies at runtime, which improves startup time and reliability
4063
RUN uv run src/agent.py download-files
4164

42-
# Start the agent
65+
# Run the application using UV
66+
# UV will activate the virtual environment and run the agent.
67+
# The "start" command tells the worker to connect to LiveKit and begin waiting for jobs.
4368
CMD ["uv", "run", "src/agent.py", "start"]

0 commit comments

Comments
 (0)