From d69128495b197be32ef3316373b6f6a5b7c3e852 Mon Sep 17 00:00:00 2001 From: cndoit18 Date: Sat, 17 May 2025 21:21:55 +0800 Subject: [PATCH] feat: add .venv to dockerignore and optimize Dockerfile with cache mounts for uv (#145) Change-Id: I27ff2d4f9bcdedbd0135e109ecb6aa6d78bc488b --- .dockerignore | 1 + Dockerfile | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 7ee04e6..3faf7a1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -26,6 +26,7 @@ wheels/ *.egg-info/ .installed.cfg *.egg +.venv/ # Web node_modules diff --git a/Dockerfile b/Dockerfile index ec4d6a8..a0d08b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,18 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv WORKDIR /app +# Pre-cache the application dependencies. +RUN --mount=type=cache,target=/root/.cache/uv \ + --mount=type=bind,source=uv.lock,target=uv.lock \ + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ + uv sync --locked --no-install-project + # Copy the application into the container. COPY . /app # Install the application dependencies. -RUN uv sync --frozen --no-cache +RUN --mount=type=cache,target=/root/.cache/uv \ + uv sync --locked EXPOSE 8000