FROM python:3.10-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ tesseract-ocr \ poppler-utils \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for caching COPY requirements.txt . # Install CPU-only PyTorch (smaller, less RAM) RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Create directories RUN mkdir -p /tmp/uploads /tmp/chroma_db # Expose port (Hugging Face Spaces uses 7860) EXPOSE 7860 # Set environment variables ENV HOST=0.0.0.0 ENV PORT=7860 ENV UPLOAD_DIR=/tmp/uploads ENV CHROMA_DIR=/tmp/chroma_db # Run the application CMD ["python", "main.py"]