Skip to content

Commit 56819c0

Browse files
committed
perf: improve Docker layer caching for faster builds
Split dependency installation from source copy: 1. Copy manifests first (pyproject.toml, uv.lock) 2. Install deps with --no-install-project (cached layer) 3. Copy source code 4. Install project with --no-deps (fast) This ensures source code changes don't invalidate the expensive ~2GB dependency installation layer.
1 parent a450d7d commit 56819c0

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ RUN uv python install 3.12 && uv venv /app/.venv --python 3.12
1515
ENV VIRTUAL_ENV=/app/.venv
1616
ENV PATH="/app/.venv/bin:$PATH"
1717

18-
# Copy project files for reproducible install
18+
# Copy manifests first to leverage layer caching
1919
COPY pyproject.toml uv.lock ./
20+
21+
# Install dependencies from lock file (cached unless deps change)
22+
RUN uv sync --frozen --no-dev --no-install-project
23+
24+
# Copy source code (changes here don't invalidate dep cache)
2025
COPY src/ ./src/
2126

22-
# Install with frozen lock file (reproducible builds)
23-
RUN uv sync --frozen --no-dev
27+
# Install the project itself (fast, no deps to resolve)
28+
RUN uv pip install --no-deps .
2429

2530
# Runtime config
2631
RUN mkdir -p /app/data

0 commit comments

Comments
 (0)