Hey team, Our current Docker image is blowing up t...
# agents
o
Hey team, Our current Docker image is blowing up to ~7GB, and because of that the application startup time is getting very slow. Here’s the Dockerfile we’re using (simplified):
Copy code
# syntax=docker/dockerfile:1.7
ARG PYTHON_VERSION=3.11
FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-bookworm-slim

ENV PYTHONUNBUFFERED=1
WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/*

COPY pyproject.toml ./
RUN mkdir -p src
COPY . .
RUN chown -R appuser:appuser /app
USER appuser

ENV SKIP_SECRETS=1
ENV SKIP_GENERATE_PROMPTS=1
ENV DOWNLOAD_DIR=downloads

RUN uv run main.py download-files
CMD ["uv", "run", "main.py", "start"]
⚡ Ask: Is there any recommended way to reduce the image size for LiveKit agents / Python apps? Would multi-stage builds or a different base image help here?
b
Using
python:3.13-slim
might help. Some other things: • Are you sure you need to do
COPY . .
? Instead of doing something more targeted like
COPY app/ ./app/
• You really shouldn't need uv in the final docker image for runtime. You only need them during build. (maybe something like
COPY --from=builder /app/.venv /app/.venv
could help? Don't forget to update the path env though)
o
This is not reducing the size
b
Hmm do you have a .dockerignore? are you ignoring dev dependencies (maybe something like
RUN uv sync --frozen --no-dev
)? The only other thing that comes to mind right now is moving the download files step to a previous stage which might help with layering (that would help more with time than size though)