FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

WORKDIR /app
COPY services/kb-query/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# kb_retrieval only -- kb-query never writes/archives mail (kb-mail) and never touches the
# documents-ingest CLI/anthropic dependency (module 5 phase 4 plan §3 decision 1: minimal deps).
# Build context is the repo root (see docker-compose.yml's build.context) so this path resolves.
COPY packages/kb-retrieval/ /packages/kb-retrieval/
RUN pip install --no-cache-dir /packages/kb-retrieval/

COPY services/kb-query/app ./app

EXPOSE 8080
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]
