FROM python:3.9 # Install system dependencies as root for OpenCV support USER root RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # Set up a new user named "user" with UID 1000 to comply with Hugging Face security RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /app # Copy dependencies first to leverage caching COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy application files COPY --chown=user . /app CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]