FROM python:3.10-slim # Add system dependencies for OpenCV, face recognition, and build tools RUN apt-get update && apt-get install -y \ # OpenCV dependencies libgl1-mesa-glx \ libglib2.0-0 \ libsm6 \ libxext6 \ libgomp1 \ # Build dependencies for dlib cmake \ build-essential \ libopenblas-dev \ liblapack-dev \ libx11-dev \ libgtk-3-dev \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY requirements.txt . # Install non-PyTorch packages first RUN pip install --no-cache-dir fastapi uvicorn[standard] numpy pillow matplotlib motor opencv-python-headless dlib face_recognition # Install PyTorch packages from specific index RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch torchvision COPY . . EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]