# Stage 1: Build — install Python deps with dev tools available FROM rocm/dev-ubuntu-24.04:6.4-complete AS builder ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ python3.12 python3.12-venv python3.12-dev python3-pip \ libpoppler-cpp-dev poppler-utils \ build-essential curl \ && rm -rf /var/lib/apt/lists/* COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv WORKDIR /app COPY pyproject.toml ./ COPY kb/ kb/ COPY main.py ./ COPY VERSION ./ RUN uv venv .venv && \ . .venv/bin/activate && \ uv pip install -e . && \ uv pip install --no-deps onnxruntime-rocm # Stage 2: Runtime — minimal ROCm runtime libs only FROM ubuntu:24.04 ENV DEBIAN_FRONTEND=noninteractive # Add ROCm apt repository RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates curl gnupg \ && mkdir -p /etc/apt/keyrings \ && curl -fsSL https://repo.radeon.com/rocm/rocm.gpg.key \ | gpg --dearmor -o /etc/apt/keyrings/rocm.gpg \ && echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/6.4.1 noble main" \ > /etc/apt/sources.list.d/rocm.list \ && printf 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600\n' \ > /etc/apt/preferences.d/rocm-pin-600 \ && apt-get update && apt-get install -y --no-install-recommends \ python3.12 python3.12-venv \ libpoppler-cpp0t64 poppler-utils \ libgl1 libglib2.0-0 \ rocm-hip-runtime \ rocm-hip-libraries \ miopen-hip \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy built venv and application from builder COPY --from=builder /app/.venv .venv COPY --from=builder /app/kb kb COPY --from=builder /app/main.py . COPY --from=builder /app/pyproject.toml . COPY --from=builder /app/VERSION . ENV PATH="/app/.venv/bin:$PATH" ENV VIRTUAL_ENV="/app/.venv" ENV KB_DEVICE=auto ENV KB_INGEST_DEVICE=auto ENV KB_DATA_DIR=/data EXPOSE 8000 VOLUME ["/data"] CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]