FROM python:3.9-slim # Install system dependencies required by OpenCV RUN apt-get update && apt-get install -y \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ && rm -rf /var/lib/apt/lists/* # Set up a non-root user for Hugging Face Spaces RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /app # Copy requirements and install COPY --chown=user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the app COPY --chown=user . . # Run the app on port 7860 (Hugging Face Spaces default) CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]