FROM python:3.11-bullseye ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 ENV MPLCONFIGDIR="/app/matplotlib" ENV DEEPFACE_HOME="/app/.deepface" RUN apt-get update && apt-get install -y \ build-essential \ cmake \ libgl1-mesa-glx \ libglib2.0-0 \ libopenblas-dev \ liblapack-dev \ libjpeg-dev \ libpng-dev \ && apt-get clean && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy only requirements first (cache-friendly) COPY requirements.txt /app/ RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Now copy the rest of your application COPY . /app # Create necessary directories and permissions RUN mkdir -p /app/matplotlib /app/.deepface /app/tmp /app/data /app/static && \ chmod -R 777 /app/.deepface /app/matplotlib /app/tmp /app/data /app/static EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "8"]