FROM python:3.10-slim WORKDIR /app # System deps RUN apt-get update && apt-get install -y \ ffmpeg \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ git \ && rm -rf /var/lib/apt/lists/* # Install CPU-only PyTorch first RUN pip install --no-cache-dir \ torch==2.4.0+cpu \ torchvision==0.19.0+cpu \ --index-url https://download.pytorch.org/whl/cpu # Install remaining deps COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-deps --no-cache-dir facenet-pytorch==2.6.0 # Copy app + static frontend files COPY app.py . COPY static/ ./static/ # Copy model checkpoint (uploaded separately to HF Space repo) COPY best_model.pth . # HF Spaces requires port 7860 EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "120"]