| FROM python:3.11-slim | |
| WORKDIR /app | |
| # System deps for sentence-transformers (tokenizers uses Rust bindings) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Pre-download models so first request isn't slow on HF Spaces | |
| RUN python -c "\ | |
| from sentence_transformers import SentenceTransformer; \ | |
| from transformers import T5Tokenizer, pipeline; \ | |
| SentenceTransformer('all-MiniLM-L6-v2'); \ | |
| tok = T5Tokenizer.from_pretrained('t5-small'); \ | |
| pipe = pipeline('text-classification', model='vectara/hallucination_evaluation_model', tokenizer=tok, trust_remote_code=True); \ | |
| pipe(['test document test response'])" | |
| COPY knowledge/ ./knowledge/ | |
| COPY backend/ ./backend/ | |
| COPY ui/ ./ui/ | |
| WORKDIR /app/backend | |
| # HF Spaces requires port 7860 | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |