Skip to content

Commit a7d8709

Browse files
authored
dockerfile updates (#56)
1 parent 6840439 commit a7d8709

3 files changed

Lines changed: 80 additions & 26 deletions

File tree

.dockerignore

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Project tests
2+
test/
3+
tests/
4+
eval/
5+
evals/
6+
17
# Python bytecode and artifacts
28
__pycache__/
39
*.py[cod]
@@ -39,10 +45,29 @@ coverage/
3945

4046
# Project docs and misc
4147
README.md
48+
CONTRIBUTING.md
4249
LICENSE
4350

44-
# Project tests
45-
test/
46-
tests/
47-
eval/
48-
evals/
51+
# Coding agent files
52+
.claude/
53+
.codex/
54+
.cursor/
55+
.windsurf/
56+
.gemini/
57+
.cline/
58+
.clinerules
59+
.clinerules/
60+
.aider*
61+
.cursorrules
62+
.cursorignore
63+
.cursorindexingignore
64+
.clineignore
65+
.codeiumignore
66+
.geminiignore
67+
.windsurfrules
68+
CLAUDE.md
69+
AGENTS.md
70+
GEMINI.md
71+
.github/copilot-instructions.md
72+
.github/personal-instructions.md
73+
.github/instructions/

.gitignore

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,24 @@ KMS
1010
*.egg-info
1111
.pytest_cache
1212
.ruff_cache
13-
.claude/settings.local.json
13+
14+
# Claude Code
15+
.claude/settings.local.json
16+
.claude/worktrees/
17+
18+
# OpenAI Codex
19+
.codex/config.local.toml
20+
21+
# Gemini CLI
22+
.gemini/history/
23+
.gemini/tmp/
24+
.gemini/google_accounts.json
25+
.gemini/installation_id
26+
.gemini/oauth_creds.json
27+
28+
# Cursor
29+
.cursor/chat/
30+
.cursor/rules/*.local.mdc
31+
32+
# GitHub CLI
33+
.github/personal-instructions.md

Dockerfile

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,13 @@ FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-bookworm-slim AS base
1010
# the application crashes without emitting any logs due to buffering.
1111
ENV PYTHONUNBUFFERED=1
1212

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 "/app" \
20-
--shell "/sbin/nologin" \
21-
--uid "${UID}" \
22-
appuser
13+
# --- Build stage ---
14+
# Install dependencies, build native extensions, and prepare the application
15+
FROM base AS build
2316

2417
# Install build dependencies required for Python packages with native extensions
2518
# gcc: C compiler needed for building Python packages with C extensions
19+
# g++: C++ compiler needed for building Python packages with C++ extensions
2620
# python3-dev: Python development headers needed for compilation
2721
# We clean up the apt cache after installation to keep the image size down
2822
RUN apt-get update && apt-get install -y \
@@ -50,20 +44,35 @@ RUN uv sync --locked
5044
# (Excludes files specified in .dockerignore)
5145
COPY . .
5246

53-
# Change ownership of all app files to the non-privileged user
54-
# This ensures the application can read/write files as needed
55-
RUN chown -R appuser:appuser /app
47+
# Pre-download any ML models or files the agent needs
48+
# This ensures the container is ready to run immediately without downloading
49+
# dependencies at runtime, which improves startup time and reliability
50+
RUN uv run "src/agent.py" download-files
51+
52+
# --- Production stage ---
53+
# Build tools (gcc, g++, python3-dev) are not included in the final image
54+
FROM base
55+
56+
# Create a non-privileged user that the app will run under.
57+
# See https://docs.docker.com/build/building/best-practices/#user
58+
ARG UID=10001
59+
RUN adduser \
60+
--disabled-password \
61+
--gecos "" \
62+
--home "/app" \
63+
--shell "/sbin/nologin" \
64+
--uid "${UID}" \
65+
appuser
66+
67+
# Copy the application and virtual environment with correct ownership in a single layer
68+
# This avoids expensive recursive chown and excludes build tools from the final image
69+
COPY --from=build --chown=appuser:appuser /app /app
5670

5771
# Switch to the non-privileged user for all subsequent operations
5872
# This improves security by not running as root
5973
USER appuser
6074

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-
# Run the application using UV
75+
# Run the AgentServer using UV
6776
# UV will activate the virtual environment and run the agent.
68-
# The "start" command tells the worker to connect to LiveKit and begin waiting for jobs.
77+
# The "start" command tells the AgentServer to connect to LiveKit and begin waiting for jobs.
6978
CMD ["uv", "run", "src/agent.py", "start"]

0 commit comments

Comments
 (0)