Spaces:
Sleeping
Sleeping
| # Hugging Face Spaces requires port 7860 and uid 1000 | |
| FROM python:3.11-slim | |
| # System dependencies for chromadb, lxml, sentence-transformers, unstructured | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| libxml2-dev \ | |
| libxslt-dev \ | |
| libsqlite3-dev \ | |
| libffi-dev \ | |
| curl \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install uv for fast dependency resolution | |
| RUN pip install --no-cache-dir uv | |
| # HF Spaces requires non-root user with uid 1000 | |
| RUN useradd -m -u 1000 -s /bin/bash appuser | |
| WORKDIR /app | |
| # Install deps before copying source (better layer caching) | |
| COPY pyproject.toml uv.lock ./ | |
| RUN uv sync --frozen --no-dev | |
| # Copy source code | |
| COPY --chown=appuser:appuser . . | |
| # Create writable runtime directories | |
| RUN mkdir -p vector_store cache documents \ | |
| && chown -R appuser:appuser /app | |
| USER appuser | |
| # Pre-download the sentence transformer model so first request is fast | |
| RUN uv run python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')" | |
| EXPOSE 7860 | |
| CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |