# Hugging Face Spaces Dockerfile FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies for WeasyPrint, pycairo and document processing RUN apt-get update && apt-get install -y \ libpango-1.0-0 \ libpangocairo-1.0-0 \ libgdk-pixbuf-2.0-0 \ libffi-dev \ shared-mime-info \ # Build dependencies for pycairo gcc \ pkg-config \ libcairo2-dev \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Create necessary directories RUN mkdir -p knowledge_base exports uploads data # Set environment variables ENV PYTHONUNBUFFERED=1 ENV PORT=7860 ENV HF_SPACES=1 # Expose port (HF Spaces uses 7860) EXPOSE 7860 # Run with gunicorn CMD ["gunicorn", "app:app", "--bind", "0.0.0.0:7860", "--workers", "2", "--threads", "4", "--timeout", "300"]