| # RAG_API_SECRET: set at runtime via HF Space "Repository secrets", not in this image. | |
| # Backend must set the same value in RAG_API_SECRET for /query and /upload to work. | |
| FROM python:3.11-slim | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /app | |
| # HF cache on ephemeral disk — bucket FS may not support symlinks needed by HF cache | |
| ENV HF_HOME="/tmp/hf_cache" | |
| # torch CPU-only (needed by sentence-transformers) | |
| RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| COPY main.py conversation.py llm_client.py reranker.py guardrails.py . | |
| RUN mkdir -p /data | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |