FROM python:3.9-slim # Install system dependencies RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ ffmpeg \ tesseract-ocr \ poppler-utils \ && rm -rf /var/lib/apt/lists/* # Set environment variables to avoid permission issues ENV MPLCONFIGDIR=/tmp/matplotlib ENV YOLO_CONFIG_DIR=/tmp/Ultralytics ENV XDG_CACHE_HOME=/tmp ENV FONTCONFIG_PATH=/tmp RUN mkdir -p /tmp/matplotlib /tmp/ultralytics /tmp/fontconfig # Set working directory WORKDIR /app # Copy project files COPY . . # Install Python dependencies RUN pip install --upgrade pip RUN pip install -r requirements.txt # Expose Hugging Face Spaces default port EXPOSE 7860 # Run FastAPI app with Uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]