|
1 | | -# GPU quote requires pynvml, which requires cuda, so use vllm image instead of python3 |
2 | | -FROM vllm/vllm-openai:v0.9.1 |
| 1 | +# syntax=docker/dockerfile:1.7 |
3 | 2 |
|
4 | | -# Install dependencies |
5 | | -WORKDIR /tmp |
| 3 | +# The proxy talks to a separate vLLM server; it doesn't need the multi-GB vLLM runtime image. |
| 4 | +# Keep the image small by using a slim Python base + venv, and rely on the NVIDIA runtime to |
| 5 | +# mount driver libraries (e.g., NVML) when GPU features are enabled. |
| 6 | +FROM python:3.12-slim-bookworm AS builder |
| 7 | + |
| 8 | +ARG UV_VERSION=0.9.17 |
| 9 | + |
| 10 | +ENV DEBIAN_FRONTEND=noninteractive \ |
| 11 | + PIP_DISABLE_PIP_VERSION_CHECK=1 \ |
| 12 | + PYTHONDONTWRITEBYTECODE=1 \ |
| 13 | + UV_NO_MANAGED_PYTHON=1 \ |
| 14 | + UV_PYTHON_DOWNLOADS=never \ |
| 15 | + UV_LINK_MODE=copy |
| 16 | + |
| 17 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 18 | + build-essential \ |
| 19 | + && rm -rf /var/lib/apt/lists/* |
| 20 | + |
| 21 | +RUN python -m pip install --no-cache-dir --upgrade pip \ |
| 22 | + && python -m pip install --no-cache-dir "uv==${UV_VERSION}" |
6 | 23 |
|
7 | | -# Install packages via requirements.txt instead of poetry |
8 | | -# because of nv-ppcie-verifier requires some old version packages, |
9 | | -# which is not compatible with lots of current dependencies. |
| 24 | +ENV VIRTUAL_ENV=/opt/venv |
| 25 | +RUN python -m venv "$VIRTUAL_ENV" |
| 26 | +ENV PATH="$VIRTUAL_ENV/bin:$PATH" |
| 27 | + |
| 28 | +WORKDIR /tmp |
10 | 29 | COPY requirements.txt ./ |
11 | | -RUN pip install --no-cache-dir --upgrade -r requirements.txt \ |
12 | | - && rm -rf requirements.txt |
| 30 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 31 | + uv pip install --strict -r requirements.txt |
| 32 | + |
| 33 | +FROM builder AS gpu-builder |
| 34 | + |
| 35 | +ENV VIRTUAL_ENV=/opt/ppcie-venv |
| 36 | +RUN python -m venv "$VIRTUAL_ENV" |
| 37 | +ENV PATH="$VIRTUAL_ENV/bin:$PATH" |
| 38 | + |
| 39 | +WORKDIR /tmp |
| 40 | +COPY requirements-gpu.txt ./ |
| 41 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 42 | + uv pip install --strict -r requirements-gpu.txt |
| 43 | + |
| 44 | +FROM python:3.12-slim-bookworm AS runtime |
| 45 | + |
| 46 | +ENV VIRTUAL_ENV=/opt/venv \ |
| 47 | + PATH="/opt/venv/bin:$PATH" \ |
| 48 | + PYTHONUNBUFFERED=1 |
| 49 | + |
| 50 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 51 | + ca-certificates \ |
| 52 | + && rm -rf /var/lib/apt/lists/* |
13 | 53 |
|
14 | | -# Copy source code |
15 | 54 | WORKDIR /app |
| 55 | +COPY --from=builder /opt/venv /opt/venv |
16 | 56 | COPY src ./ |
17 | | -EXPOSE 8000 |
18 | 57 |
|
| 58 | +EXPOSE 8000 |
19 | 59 | ENTRYPOINT ["./entrypoint.sh"] |
| 60 | + |
| 61 | +FROM runtime AS runtime-gpu |
| 62 | +COPY --from=gpu-builder /opt/ppcie-venv /opt/ppcie-venv |
| 63 | +ENV GPU_EVIDENCE_PYTHON=/opt/ppcie-venv/bin/python |
| 64 | +ENV NVIDIA_VISIBLE_DEVICES=all |
| 65 | +ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility |
0 commit comments