# ai-ingest — on demand, not a service. Docling parse -> chunk -> embed -> pg-ai.
FROM python:3.12-slim

# Docling pulls layout models at first use; give it the system libs it needs.
RUN apt-get update \
 && apt-get install -y --no-install-recommends libgl1 libglib2.0-0 \
 && rm -rf /var/lib/apt/lists/*

RUN useradd --create-home --uid 10002 ingestuser

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --requirement requirements.txt
COPY . .

USER ingestuser

# /docs is /datadisk/ai-docs mounted read-only. Model caches land in the
# container's home, not on the root disk of the host.
ENV HF_HOME=/home/ingestuser/.cache/huggingface
ENV AI_DOCS_ROOT=/docs

ENTRYPOINT ["python", "ingest.py"]
CMD ["--help"]
