FROM python:3.10-slim # Build tools for InsightFace's Cython extension, plus shared libs OpenCV needs RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender1 \ && rm -rf /var/lib/apt/lists/* # Hugging Face Spaces run the container as UID 1000 RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ INSIGHTFACE_HOME=/tmp/.insightface \ MPLCONFIGDIR=/tmp/matplotlib WORKDIR $HOME/app COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt COPY --chown=user . . EXPOSE 7860 CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]