Skip to content

Commit f200fa9

Browse files
committed
Changes
1 parent a66907e commit f200fa9

File tree

5 files changed

+119
-1
lines changed

5 files changed

+119
-1
lines changed

.dockerignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*.egg-info
2+
__pycache__
3+
.pytest_cache
4+
.ruff_cache
5+
.env
6+
.env.*
7+
.DS_Store
8+
.idea
9+
.venv
10+
.vscode
11+
*.pyc
12+
*.pyo
13+
*.pyd
14+
.git
15+
.gitignore
16+
README.md
17+
LICENSE
18+
.github

.github/workflows/tests.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515

16+
# As this is a starter template project, we don't want to check in the uv.lock and livekit.toml files in its template form
17+
# However, once you have cloned this repo for your own use, LiveKit recommends you check them in and remove this check
18+
- name: Check files not tracked in git
19+
run: |
20+
if git ls-files | grep -q "^uv\.lock$"; then
21+
echo "Error: uv.lock should not be checked into git"
22+
echo "Disable this test and commit the file once you have cloned this repo for your own use"
23+
exit 1
24+
fi
25+
if git ls-files | grep -q "^livekit\.toml$"; then
26+
echo "Error: livekit.toml should not be checked into git"
27+
echo "Disable this test and commit the file once you have cloned this repo for your own use"
28+
exit 1
29+
fi
30+
echo "✓ uv.lock and livekit.toml are correctly not tracked in git"
31+
1632
- name: Install uv
1733
uses: astral-sh/setup-uv@v1
1834
with:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
__pycache__
55
.idea
66
KMS
7-
uv.lock
87
.venv
98
.vscode
109
*.egg-info

Dockerfile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This sample Dockerfile creates a production-ready container for a LiveKit voice AI agent
2+
# syntax=docker/dockerfile:1
3+
4+
# Use the official UV Python base image with Python 3.11 on Debian Bookworm
5+
# UV is a fast Python package manager that provides better performance than pip
6+
# We use the slim variant to keep the image size smaller while still having essential tools
7+
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim
8+
9+
# Keeps Python from buffering stdout and stderr to avoid situations where
10+
# the application crashes without emitting any logs due to buffering.
11+
ENV PYTHONUNBUFFERED=1
12+
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
16+
RUN adduser \
17+
--disabled-password \
18+
--gecos "" \
19+
--home "/home/appuser" \
20+
--shell "/sbin/nologin" \
21+
--uid "${UID}" \
22+
appuser
23+
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
28+
RUN apt-get update && \
29+
apt-get install -y \
30+
gcc \
31+
python3-dev \
32+
&& rm -rf /var/lib/apt/lists/*
33+
34+
# Set the working directory to the user's home directory
35+
# This is where our application code will live
36+
WORKDIR /home/appuser
37+
38+
# Copy all application files into the container
39+
# This includes source code, configuration files, and dependency specifications
40+
# (Excludes files specified in .dockerignore)
41+
COPY . .
42+
43+
# Change ownership of all app files to the non-privileged user
44+
# This ensures the application can read/write files as needed
45+
RUN chown -R appuser:appuser /home/appuser
46+
47+
# Switch to the non-privileged user for all subsequent operations
48+
# This improves security by not running as root
49+
USER appuser
50+
51+
# Create a cache directory for the user
52+
# This is used by UV and Python for caching packages and bytecode
53+
RUN mkdir -p /home/appuser/.cache
54+
55+
# Install Python dependencies using UV's lock file
56+
# --locked ensures we use exact versions from uv.lock for reproducible builds
57+
# This creates a virtual environment and installs all dependencies
58+
# Ensure your uv.lock file is checked in for consistency across environments
59+
RUN uv sync --locked
60+
61+
# Pre-download any ML models or files the agent needs
62+
# This ensures the container is ready to run immediately without downloading
63+
# dependencies at runtime, which improves startup time and reliability
64+
RUN uv run src/agent.py download-files
65+
66+
# Expose the healthcheck port
67+
# This allows Docker and orchestration systems to check if the container is healthy
68+
EXPOSE 8081
69+
70+
# Run the application using UV
71+
# UV will activate the virtual environment and run the agent
72+
# The "start" command tells the worker to connect to LiveKit and begin waiting for jobs
73+
CMD ["uv", "run", "src/agent.py", "start"]

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ This project includes a complete suite of evals, based on the LiveKit Agents [te
8484
uv run pytest evals
8585
```
8686

87+
## Using this template repo for your own project
88+
89+
Once you've started your own project based on this repo, you should:
90+
91+
1. **Check in your `uv.lock`**: This file is currently untracked for the template, but you should commit it to your repository for reproducible builds and proper configuration management. (The same applies to `livekit.toml`, if you run your agents in LiveKit Cloud)
92+
93+
2. **Remove the git tracking test**: Delete the "Check files not tracked in git" step from `.github/workflows/tests.yml` since you'll now want this file to be tracked. These are just there for development purposes in the template repo itself.
94+
95+
## Deploying to production
96+
97+
This project is production-ready and includes a working `Dockerfile`. To deploy it to LiveKit Cloud or another environment, see the [deploying to production](https://docs.livekit.io/agents/ops/deployment/) guide.
98+
8799
## License
88100

89101
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)