Skip to content

Commit ad73ec7

Browse files
authored
Cache download-files in Dockerfile templates by using standalone commands (#848)
1 parent 8ea1c99 commit ad73ec7

3 files changed

Lines changed: 18 additions & 16 deletions

File tree

pkg/agentfs/examples/node.Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ COPY package.json pnpm-lock.yaml ./
3535
# --frozen-lockfile ensures we use exact versions from pnpm-lock.yaml for reproducible builds
3636
RUN pnpm install --frozen-lockfile
3737

38+
# Pre-download any ML models or files the agent needs
39+
# This runs before COPY . . so the download layer is cached across code-only changes.
40+
# The standalone CLI discovers installed @livekit/agents-plugin-* packages without
41+
# loading your agent code.
42+
RUN npx livekit-agents download-files
43+
3844
# Copy all remaining application files into the container
3945
# This includes source code, configuration files, and dependency specifications
4046
# (Excludes files specified in .dockerignore)
@@ -44,12 +50,6 @@ COPY . .
4450
# Your package.json must contain a "build" script, such as `"build": "tsc"`
4551
RUN pnpm build
4652

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-
# Your package.json must contain a "download-files" script, such as `"download-files": "pnpm run build && node dist/agent.js download-files"`
51-
RUN pnpm download-files
52-
5353
# Remove dev dependencies for a leaner production image
5454
RUN pnpm prune --prod
5555

pkg/agentfs/examples/python.pip.Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ RUN python -m venv .venv
4242
ENV PATH="/app/.venv/bin:$PATH"
4343
RUN pip install --no-cache-dir -r requirements.txt
4444

45+
# Pre-download any ML models or files the agent needs
46+
# This runs before COPY . . so the download layer is cached across code-only changes.
47+
# The module-level command discovers installed livekit-plugins-* packages without
48+
# loading your agent code.
49+
RUN python -m livekit.agents download-files
50+
4551
# Copy all remaining application files into the container
4652
# This includes source code, configuration files, and dependency specifications
4753
# (Excludes files specified in .dockerignore)
4854
COPY . .
4955

50-
# Pre-download any ML models or files the agent needs
51-
# This ensures the container is ready to run immediately without downloading
52-
# dependencies at runtime, which improves startup time and reliability
53-
RUN python "{{.ProgramMain}}" download-files
54-
5556
# --- Production stage ---
5657
# Build tools (gcc, g++, python3-dev) are not included in the final image
5758
FROM base

pkg/agentfs/examples/python.uv.Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ RUN mkdir -p src
4646
# Ensure your uv.lock file is checked in for consistency across environments
4747
RUN uv sync --locked
4848

49+
# Pre-download any ML models or files the agent needs
50+
# This runs before COPY . . so the download layer is cached across code-only changes.
51+
# The module-level command discovers installed livekit-plugins-* packages without
52+
# loading your agent code.
53+
RUN uv run --module livekit.agents download-files
54+
4955
# Copy all remaining application files into the container
5056
# This includes source code, configuration files, and dependency specifications
5157
# (Excludes files specified in .dockerignore)
5258
COPY . .
5359

54-
# Pre-download any ML models or files the agent needs
55-
# This ensures the container is ready to run immediately without downloading
56-
# dependencies at runtime, which improves startup time and reliability
57-
RUN uv run "{{.ProgramMain}}" download-files
58-
5960
# --- Production stage ---
6061
# Build tools (gcc, g++, python3-dev) are not included in the final image
6162
FROM base

0 commit comments

Comments
 (0)