# Dockerfile for Hugging Face Spaces # Uses Python 3.9 with minimal dependencies FROM python:3.9-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ g++ \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application files COPY app.py . COPY templates/ ./templates/ COPY data/ ./data/ # Create necessary directories RUN mkdir -p static vector_store # Set environment variables for Hugging Face ENV HF_SPACE=True ENV PORT=7860 ENV PYTHONUNBUFFERED=1 ENV PYTHONPATH=/app # Expose port EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/api/health')" # Run the application CMD ["python", "app.py"]