Skip to content

Commit fce5dc0

Browse files
committed
Update Dockerfile
1 parent 7ea87a3 commit fce5dc0

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

Dockerfile

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1+
# syntax=docker/dockerfile:1
2+
13
FROM python:3.11-slim-bookworm
24

35
WORKDIR /app
46

5-
# Install system deps (minimal)
6-
RUN apt-get update && apt-get install -y --no-install-recommends \
7-
curl \
8-
&& rm -rf /var/lib/apt/lists/*
7+
# Install uv (better: copy the static binary from the official uv image)
8+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
99

10-
# Install uv
11-
RUN pip install --no-cache-dir uv
10+
# Optional but common: keep uv caches in a known place
11+
ENV UV_CACHE_DIR=/root/.cache/uv
1212

13-
# Copy dependency files first (better cache)
14-
COPY pyproject.toml uv.lock* ./
13+
# Copy only dependency inputs first for better Docker layer caching
14+
COPY pyproject.toml uv.lock ./
1515

16-
# Install dependencies
17-
RUN uv install --no-cache-dir .
16+
# Create/sync the project environment from the lockfile
17+
# --frozen: fail if lock and project metadata don't match; don't update the lock
18+
# --no-dev: skip dev dependency groups in the final image
19+
RUN --mount=type=cache,target=/root/.cache/uv \
20+
uv sync --frozen --no-dev
1821

19-
# Copy app code
22+
# Now copy the rest of the app
2023
COPY . .
2124

22-
EXPOSE 8000
25+
# Make sure the venv's executables are on PATH
26+
ENV PATH="/app/.venv/bin:$PATH"
2327

24-
CMD ["python", "tests/mock_server.py"]
28+
EXPOSE 8000
29+
CMD ["uv", "run", "--frozen", "python", "tests/mock_server.py"]

0 commit comments

Comments
 (0)