Skip to content

Commit 279d1f1

Browse files
authored
Merge pull request #3 from livekit-examples/bcherry/deploy
Add deployment instructions and working Dockerfile
2 parents a66907e + 642566f commit 279d1f1

File tree

6 files changed

+150
-6
lines changed

6 files changed

+150
-6
lines changed

.dockerignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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
19+
tests/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# 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
2+
# However, once you have cloned this repo for your own use, LiveKit recommends you check them in and delete this github workflow entirely
3+
4+
name: Template Check
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
check-template-files:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Check template files not tracked in git
20+
run: |
21+
if git ls-files | grep -q "^uv\.lock$"; then
22+
echo "Error: uv.lock should not be checked into git"
23+
echo "Disable this test and commit the file once you have cloned this repo for your own use"
24+
exit 1
25+
fi
26+
if git ls-files | grep -q "^livekit\.toml$"; then
27+
echo "Error: livekit.toml should not be checked into git"
28+
echo "Disable this test and commit the file once you have cloned this repo for your own use"
29+
exit 1
30+
fi
31+
echo "✓ uv.lock and livekit.toml are correctly not tracked in git"

.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: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,44 @@ In production, use the `start` command:
6868
uv run python src/agent.py start
6969
```
7070

71-
## Web and mobile frontends
71+
## Frontend & Telephony
7272

73-
To use a prebuilt frontend or build your own, see the [agents frontend guide](https://docs.livekit.io/agents/start/frontend/).
73+
Get started quickly with our pre-built frontend starter apps, or add telephony support:
7474

75-
## Telephony
75+
| Platform | Link | Description |
76+
|----------|----------|-------------|
77+
| **Web** | [`livekit-examples/agent-starter-react`](https://github.com/livekit-examples/agent-starter-react) | Web voice AI assistant with React & Next.js |
78+
| **iOS/macOS** | [`livekit-examples/agent-starter-swift`](https://github.com/livekit-examples/agent-starter-swift) | Native iOS, macOS, and visionOS voice AI assistant |
79+
| **Flutter** | [`livekit-examples/agent-starter-flutter`](https://github.com/livekit-examples/agent-starter-flutter) | Cross-platform voice AI assistant app |
80+
| **React Native** | [`livekit-examples/voice-assistant-react-native`](https://github.com/livekit-examples/voice-assistant-react-native) | Native mobile app with React Native & Expo |
81+
| **Android** | [`livekit-examples/agent-starter-android`](https://github.com/livekit-examples/agent-starter-android) | Native Android app with Kotlin & Jetpack Compose |
82+
| **Web Embed** | [`livekit-examples/agent-starter-embed`](https://github.com/livekit-examples/agent-starter-embed) | Voice AI widget for any website |
83+
| **Telephony** | [📚 Documentation](https://docs.livekit.io/agents/start/telephony/) | Add inbound or outbound calling to your agent |
7684

77-
To add a phone number, see the [agents telephony guide](https://docs.livekit.io/agents/start/telephony/).
85+
For advanced customization, see the [complete frontend guide](https://docs.livekit.io/agents/start/frontend/).
7886

7987
## Tests and evals
8088

8189
This project includes a complete suite of evals, based on the LiveKit Agents [testing & evaluation framework](https://docs.livekit.io/agents/build/testing/). To run them, use `pytest`.
8290

8391
```console
84-
uv run pytest evals
92+
uv run pytest
8593
```
8694

95+
## Using this template repo for your own project
96+
97+
Once you've started your own project based on this repo, you should:
98+
99+
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)
100+
101+
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.
102+
103+
3. **Add your own repository secrets**: You must [add secrets](https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/using-secrets-in-github-actions) for `OPENAI_API_KEY` or your other LLM provider so that the tests can run in CI.
104+
105+
## Deploying to production
106+
107+
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.
108+
87109
## License
88110

89111
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
File renamed without changes.

0 commit comments

Comments
 (0)