acceptable-dream-85180
07/28/2025, 7:51 PMCMD [ "node", "./dist/agent.js", "start" ]tall-airline-16756
07/28/2025, 7:51 PMtall-airline-16756
07/28/2025, 7:52 PMlk create agent assumes a Node.js environment because the CLI detects the project type based on the directory contents. If it identifies the project as Node.js, it uses a template designed for Node.js agents.
The generated Dockerfile includes the following:
• Build process using pnpm install --frozen-lockfile and npm run build to compile TypeScript.
• Compiled JavaScript output in the ./dist/ directory.
• Entry point set to ./dist/agent.js.
• Default start command: CMD [ "node", "./dist/agent.js", "start" ].
This structure aligns with LiveKit's standard Node.js agent workflow, where the start command launches the worker and waits for users to connect to your LiveKit server. If your project is not Node.js-based, you may need to create a custom Dockerfile tailored to your environment.
Sources: cmd/lk/agent.go | taskfile.yaml | taskfile.yaml | agents/package.jsonacceptable-dream-85180
07/28/2025, 7:53 PM# This sample Dockerfile creates a production-ready container for a LiveKit voice AI agent
# syntax=docker/dockerfile:1
# Use the official UV Python base image with Python 3.11 on Debian Bookworm
# UV is a fast Python package manager that provides better performance than pip
# We use the slim variant to keep the image size smaller while still having essential tools
FROM <http://ghcr.io/astral-sh/uv:python3.11-bookworm-slim|ghcr.io/astral-sh/uv:python3.11-bookworm-slim>
# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1
# Create a non-privileged user that the app will run under.
# See <https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user>
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/home/appuser" \
--shell "/sbin/nologin" \
--uid "${UID}" \
appuser
# Install build dependencies required for Python packages with native extensions
# gcc: C compiler needed for building Python packages with C extensions
# python3-dev: Python development headers needed for compilation
# We clean up the apt cache after installation to keep the image size down
RUN apt-get update && \
apt-get install -y \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory to the user's home directory
# This is where our application code will live
WORKDIR /home/appuser
# Copy all application files into the container
# This includes source code, configuration files, and dependency specifications
# (Excludes files specified in .dockerignore)
COPY . .
# Change ownership of all app files to the non-privileged user
# This ensures the application can read/write files as needed
RUN chown -R appuser:appuser /home/appuser
# Switch to the non-privileged user for all subsequent operations
# This improves security by not running as root
USER appuser
# Create a cache directory for the user
# This is used by UV and Python for caching packages and bytecode
RUN mkdir -p /home/appuser/.cache
# Install Python dependencies using UV's lock file
# --locked ensures we use exact versions from uv.lock for reproducible builds
# This creates a virtual environment and installs all dependencies
# Ensure your uv.lock file is checked in for consistency across environments
RUN uv sync --locked
# Pre-download any ML models or files the agent needs
# This ensures the container is ready to run immediately without downloading
# dependencies at runtime, which improves startup time and reliability
RUN uv run src/agent.py download-files
# Expose the healthcheck port
# This allows Docker and orchestration systems to check if the container is healthy
EXPOSE 8081
# Run the application using UV
# UV will activate the virtual environment and run the agent
# The "start" command tells the worker to connect to LiveKit and begin waiting for jobs
CMD ["uv", "run", "src/agent.py", "start"]tall-airline-16756
07/28/2025, 7:54 PM# Use the official Python 3.11 slim image
FROM python:3.11-slim
# Prevent Python from buffering stdout and stderr
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Create a non-privileged user
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/home/appuser" \
--shell "/sbin/nologin" \
--uid "${UID}" \
appuser
# Install build dependencies
RUN apt-get update && \
apt-get install -y \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Switch to the non-privileged user
USER appuser
RUN mkdir -p /home/appuser/.cache
RUN chown -R appuser /home/appuser/.cache
# Set the working directory
WORKDIR /home/appuser
# Copy and install Python dependencies
COPY requirements.txt .
RUN python -m pip install --user --no-cache-dir -r requirements.txt
# Copy application files
COPY . .
# Pre-download any required models or files
RUN python src/agent.py download-files
# Expose the healthcheck port
EXPOSE 8081
# Run the application
CMD ["python", "src/agent.py", "start"]
### Steps to Implement:
1. Create a requirements.txt file listing all your Python dependencies. For example:
livekit-agents
aiohttp
av
click
colorama
docstring-parser
livekit
numpy
pydantic
protobuf
1. Replace the UV-specific commands in your Dockerfile with the above modifications.
2. Build and test the Docker image to ensure it works as expected.
Don't worry – this approach keeps everything running perfectly while using good ol' pip for managing your dependencies. You've got this!
Sources: uv.lock | agent/Dockerfile | python-agent-example-app/README.md