Spaces:
Sleeping
Sleeping
| # ========================================================= | |
| # Dockerfile for Hugging Face Spaces (Docker SDK) | |
| # ========================================================= | |
| FROM python:3.10-slim | |
| # System deps needed by faiss / sentence-transformers / reportlab | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a non-root user (required convention for HF Spaces) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONUNBUFFERED=1 \ | |
| HF_HOME=/home/user/.cache/huggingface \ | |
| TRANSFORMERS_CACHE=/home/user/.cache/huggingface | |
| WORKDIR $HOME/app | |
| # Install Python deps first (better layer caching) | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the app | |
| COPY --chown=user . . | |
| # Hugging Face Spaces expects the app to listen on port 7860 | |
| EXPOSE 7860 | |
| # Use gunicorn with a long timeout — first request loads the embedding model | |
| CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "2", "--timeout", "300", "app:app"] |