dockerfile updates (#56)
This commit is contained in:
+30
-5
@@ -1,3 +1,9 @@
|
|||||||
|
# Project tests
|
||||||
|
test/
|
||||||
|
tests/
|
||||||
|
eval/
|
||||||
|
evals/
|
||||||
|
|
||||||
# Python bytecode and artifacts
|
# Python bytecode and artifacts
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
@@ -39,10 +45,29 @@ coverage/
|
|||||||
|
|
||||||
# Project docs and misc
|
# Project docs and misc
|
||||||
README.md
|
README.md
|
||||||
|
CONTRIBUTING.md
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
# Project tests
|
# Coding agent files
|
||||||
test/
|
.claude/
|
||||||
tests/
|
.codex/
|
||||||
eval/
|
.cursor/
|
||||||
evals/
|
.windsurf/
|
||||||
|
.gemini/
|
||||||
|
.cline/
|
||||||
|
.clinerules
|
||||||
|
.clinerules/
|
||||||
|
.aider*
|
||||||
|
.cursorrules
|
||||||
|
.cursorignore
|
||||||
|
.cursorindexingignore
|
||||||
|
.clineignore
|
||||||
|
.codeiumignore
|
||||||
|
.geminiignore
|
||||||
|
.windsurfrules
|
||||||
|
CLAUDE.md
|
||||||
|
AGENTS.md
|
||||||
|
GEMINI.md
|
||||||
|
.github/copilot-instructions.md
|
||||||
|
.github/personal-instructions.md
|
||||||
|
.github/instructions/
|
||||||
|
|||||||
+20
@@ -10,4 +10,24 @@ KMS
|
|||||||
*.egg-info
|
*.egg-info
|
||||||
.pytest_cache
|
.pytest_cache
|
||||||
.ruff_cache
|
.ruff_cache
|
||||||
|
|
||||||
|
# Claude Code
|
||||||
.claude/settings.local.json
|
.claude/settings.local.json
|
||||||
|
.claude/worktrees/
|
||||||
|
|
||||||
|
# OpenAI Codex
|
||||||
|
.codex/config.local.toml
|
||||||
|
|
||||||
|
# Gemini CLI
|
||||||
|
.gemini/history/
|
||||||
|
.gemini/tmp/
|
||||||
|
.gemini/google_accounts.json
|
||||||
|
.gemini/installation_id
|
||||||
|
.gemini/oauth_creds.json
|
||||||
|
|
||||||
|
# Cursor
|
||||||
|
.cursor/chat/
|
||||||
|
.cursor/rules/*.local.mdc
|
||||||
|
|
||||||
|
# GitHub CLI
|
||||||
|
.github/personal-instructions.md
|
||||||
|
|||||||
+29
-20
@@ -10,19 +10,13 @@ FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-bookworm-slim AS base
|
|||||||
# the application crashes without emitting any logs due to buffering.
|
# the application crashes without emitting any logs due to buffering.
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
# Create a non-privileged user that the app will run under.
|
# --- Build stage ---
|
||||||
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
|
# Install dependencies, build native extensions, and prepare the application
|
||||||
ARG UID=10001
|
FROM base AS build
|
||||||
RUN adduser \
|
|
||||||
--disabled-password \
|
|
||||||
--gecos "" \
|
|
||||||
--home "/app" \
|
|
||||||
--shell "/sbin/nologin" \
|
|
||||||
--uid "${UID}" \
|
|
||||||
appuser
|
|
||||||
|
|
||||||
# Install build dependencies required for Python packages with native extensions
|
# Install build dependencies required for Python packages with native extensions
|
||||||
# gcc: C compiler needed for building Python packages with C extensions
|
# gcc: C compiler needed for building Python packages with C extensions
|
||||||
|
# g++: C++ compiler needed for building Python packages with C++ extensions
|
||||||
# python3-dev: Python development headers needed for compilation
|
# python3-dev: Python development headers needed for compilation
|
||||||
# We clean up the apt cache after installation to keep the image size down
|
# We clean up the apt cache after installation to keep the image size down
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
@@ -50,20 +44,35 @@ RUN uv sync --locked
|
|||||||
# (Excludes files specified in .dockerignore)
|
# (Excludes files specified in .dockerignore)
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Change ownership of all app files to the non-privileged user
|
# Pre-download any ML models or files the agent needs
|
||||||
# This ensures the application can read/write files as needed
|
# This ensures the container is ready to run immediately without downloading
|
||||||
RUN chown -R appuser:appuser /app
|
# dependencies at runtime, which improves startup time and reliability
|
||||||
|
RUN uv run "src/agent.py" download-files
|
||||||
|
|
||||||
|
# --- Production stage ---
|
||||||
|
# Build tools (gcc, g++, python3-dev) are not included in the final image
|
||||||
|
FROM base
|
||||||
|
|
||||||
|
# Create a non-privileged user that the app will run under.
|
||||||
|
# See https://docs.docker.com/build/building/best-practices/#user
|
||||||
|
ARG UID=10001
|
||||||
|
RUN adduser \
|
||||||
|
--disabled-password \
|
||||||
|
--gecos "" \
|
||||||
|
--home "/app" \
|
||||||
|
--shell "/sbin/nologin" \
|
||||||
|
--uid "${UID}" \
|
||||||
|
appuser
|
||||||
|
|
||||||
|
# Copy the application and virtual environment with correct ownership in a single layer
|
||||||
|
# This avoids expensive recursive chown and excludes build tools from the final image
|
||||||
|
COPY --from=build --chown=appuser:appuser /app /app
|
||||||
|
|
||||||
# Switch to the non-privileged user for all subsequent operations
|
# Switch to the non-privileged user for all subsequent operations
|
||||||
# This improves security by not running as root
|
# This improves security by not running as root
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
# Pre-download any ML models or files the agent needs
|
# Run the AgentServer using UV
|
||||||
# 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
|
|
||||||
|
|
||||||
# Run the application using UV
|
|
||||||
# UV will activate the virtual environment and run the agent.
|
# 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.
|
# The "start" command tells the AgentServer to connect to LiveKit and begin waiting for jobs.
|
||||||
CMD ["uv", "run", "src/agent.py", "start"]
|
CMD ["uv", "run", "src/agent.py", "start"]
|
||||||
|
|||||||
Reference in New Issue
Block a user