FROM python:3.10-slim WORKDIR /app # Install system dependencies for PyMuPDF and other packages RUN apt-get update && apt-get install -y \ build-essential \ libffi-dev \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for Docker layer caching COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Create necessary directories RUN mkdir -p uploads chroma_data # Hugging Face Spaces uses port 7860 EXPOSE 7860 # Set environment variables ENV FLASK_ENV=production ENV PYTHONUNBUFFERED=1 # Run with gunicorn for production CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--worker-class", "gthread", "--threads", "4", "--workers", "2", "--timeout", "1200", "--access-logfile", "-", "--error-logfile", "-", "app:app"]