FROM python:3.11-slim WORKDIR /app # Set environment variables for writable directories ENV INSIGHTFACE_HOME=/tmp/.insightface ENV MPLCONFIGDIR=/tmp/matplotlib # Install system dependencies for OpenCV and InsightFace RUN apt-get update && apt-get install -y \ build-essential \ g++ \ libgl1 \ libglib2.0-0 \ libgomp1 \ libgthread-2.0-0 \ libsm6 \ libxext6 \ libxrender1 \ libfontconfig1 \ libice6 \ mesa-utils \ wget \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY app ./app # (Optional) expose port 7860 or 80 EXPOSE 80 CMD ["fastapi", "run", "app/main.py", "--host", "0.0.0.0", "--port", "7860"]