| FROM python:3.11-slim | |
| # Environment variables for HF Spaces | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV HF_HOME=/tmp/huggingface | |
| ENV TRANSFORMERS_CACHE=/tmp/huggingface | |
| ENV TOKENIZERS_PARALLELISM=false | |
| # Flag to indicate we're running on HF Spaces | |
| ENV HF_SPACE=1 | |
| # Site branding for HF Spaces | |
| ENV SITE_TITLE="Zeta Researcher Light" | |
| # Default to lightweight embedding model for cloud deployment (E5-small: CPU-optimized) | |
| ENV EMBEDDING_MODEL=intfloat/e5-small-v2 | |
| ENV EMBEDDING_DEVICE=cpu | |
| # ChromaDB and shares directories (writable on HF Spaces) | |
| ENV CHROMA_PERSIST_DIR=/tmp/chromadb | |
| ENV SHARES_DIR=/tmp/shares | |
| # Install system dependencies (including PDF libraries) | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| libpoppler-cpp-dev \ | |
| poppler-utils \ | |
| tesseract-ocr \ | |
| libmagic1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set working directory | |
| WORKDIR /app | |
| # Install Python dependencies first (for better caching) | |
| # Use lightweight requirements (no NV-Embed-v2/GPU deps, no dev tools) | |
| COPY requirements-light.txt . | |
| RUN pip install --no-cache-dir -r requirements-light.txt | |
| # Copy application code | |
| COPY . . | |
| # Create necessary directories | |
| RUN mkdir -p /tmp/chromadb /tmp/huggingface /tmp/shares logs | |
| # Make entrypoint executable | |
| RUN chmod +x /app/scripts/docker_entrypoint.sh | |
| # Pre-download the embedding model during build | |
| RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('intfloat/e5-small-v2')" | |
| # Expose HF Spaces port | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=30s --start-period=120s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| # Run via entrypoint script (extracts embeddings on first run) | |
| CMD ["/app/scripts/docker_entrypoint.sh"] | |