build(docker): speed up builds with uv package manager and BuildKit cache #22

Merged
amit merged 1 commits from build/docker-uv-optimization into main 2026-11-02 04:48:26 +00:00
2 changed files with 12 additions and 5 deletions

View File

@ -1,2 +1,2 @@
Branch: invoice-update Branch: main
Commit: 50538bb64faa7f46d643ed60b9f0f272d5624a39 Commit: 895342a8ba976caa41f4b5b9fdec1c684e47dc5d

View File

@ -15,7 +15,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Copy pyproject.toml first for layer caching # Prefer IPv4 over unrouted IPv6 in glibc to prevent PyPI connection timeouts
RUN echo "precedence ::ffff:0:0/96 100" >> /etc/gai.conf
# Use Astral's uv package manager for fast, parallel, cached installations
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
ENV UV_HTTP_TIMEOUT=300
# Copy pyproject.toml first
COPY pyproject.toml ./ COPY pyproject.toml ./
COPY README.md ./ COPY README.md ./
@ -26,8 +33,8 @@ COPY app ./app
# Copy git info metadata if generated on host # Copy git info metadata if generated on host
COPY .git_api_info* /app/.git_api_info COPY .git_api_info* /app/.git_api_info
# Install project and CLI scripts into PATH # Install project and CLI scripts into system PATH using persistent BuildKit cache
RUN pip install --no-cache-dir -e . RUN --mount=type=cache,target=/root/.cache/uv uv pip install --system -e .
EXPOSE 8000 EXPOSE 8000