# Use a lightweight Python base image FROM python:3.10-slim # Install system dependencies for OCR and Chromium RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ wget \ gnupg \ chromium \ chromium-driver \ libreoffice \ ghostscript \ tesseract-ocr \ poppler-utils \ default-jre \ && rm -rf /var/lib/apt/lists/* # Set environment variables for DrissionPage/Chromium ENV CHROME_BIN=/usr/bin/chromium ENV CHROMEDRIVER_PATH=/usr/bin/chromedriver # Create application directory WORKDIR /app # Copy requirements and install COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Pre-download models to avoid startup timeouts in Hugging Face Spaces # This ensures rembg and easyocr models are ready RUN python -c "import rembg; rembg.new_session('isnet-general-use')" RUN python -c "import easyocr; easyocr.Reader(['en', 'de'], gpu=False)" # Copy application code COPY . . # Expose the default Hugging Face port EXPOSE 7860 # Run the application CMD ["python", "main.py"]