| # ββ Hugging Face Spaces β Docker SDK ββββββββββββββββββββββββββ | |
| # HF Spaces requires port 7860 and the app to listen on 0.0.0.0 | |
| # SDK: docker (set in the Space README YAML frontmatter) | |
| FROM python:3.10-slim | |
| # System deps for faiss-cpu, pymupdf, sentence-transformers | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Install Python deps first (layer cache) | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Pre-download the sentence-transformers model so it is baked into the image | |
| RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')" | |
| # Copy backend source | |
| COPY backend/ ./backend/ | |
| # HF Spaces exposes port 7860 | |
| EXPOSE 7860 | |
| # main.py uses relative imports (from core.x, from quiz.x) | |
| # so we must run uvicorn from inside the backend/ directory | |
| WORKDIR /app/backend | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |