Spaces:
Sleeping
Sleeping
| FROM python:3.9-slim | |
| RUN apt-get update && apt-get install -y \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| RUN useradd -m -u 1000 user | |
| RUN mkdir -p /home/user/.deepface/weights && \ | |
| mkdir -p /app/faces_db && \ | |
| mkdir -p /app/data && \ | |
| mkdir -p /app/core /app/api /app/services /app/static /app/templates && \ | |
| chown -R user:user /app && \ | |
| chown -R user:user /home/user/.deepface | |
| # Pre-download SOTA weights (ArcFace, Facenet512, & RetinaFace) to ensure zero-lag startup | |
| RUN wget https://github.com/serengil/deepface_models/releases/download/v1.0/arcface_weights.h5 \ | |
| -O /home/user/.deepface/weights/arcface_weights.h5 && \ | |
| wget https://github.com/serengil/deepface_models/releases/download/v1.0/facenet512_weights.h5 \ | |
| -O /home/user/.deepface/weights/facenet512_weights.h5 && \ | |
| wget https://github.com/serengil/deepface_models/releases/download/v1.0/retinaface.h5 \ | |
| -O /home/user/.deepface/weights/retinaface.h5 | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| COPY --chown=user requirements.txt . | |
| # 1. Install base libraries | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # 2. Install DeepFace helpers | |
| RUN pip install --no-cache-dir gdown fire tqdm Pillow requests Flask gunicorn | |
| # 3. CRITICAL: Install deepface and retina-face without pulling conflicting deps | |
| RUN pip install --no-cache-dir retina-face deepface --no-deps | |
| COPY --chown=user . . | |
| # Ensure all subdirectories are treated as packages | |
| RUN touch core/__init__.py api/__init__.py services/__init__.py | |
| # Run FastAPI app | |
| CMD ["python", "app.py"] | |