File size: 5,212 Bytes
ec6c3ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dace3a8
ec6c3ca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
��FROM python:3.10-slim



ENV PYTHONUNBUFFERED=1 \

    PYTHONUTF8=1 \

    PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python \

    # On Hugging Face CPU Spaces, warmup of heavy ML models can exceed container

    # startup time and cause apparent hangs. Set to 1 to skip warmup during

    # container start (models still lazy-load on first request).

    FAKESHIELD_SKIP_WARMUP=1



WORKDIR /app



# System dependencies (Adding build-essential for C extensions)

RUN apt-get update && apt-get install -y --no-install-recommends \

    build-essential \

    libgl1 \

    libglib2.0-0 \

    libsndfile1 \

    ffmpeg \

    libmagic1 \

    libgles2 \

    libegl1 \

    && rm -rf /var/lib/apt/lists/*



COPY backend/requirements.txt .



RUN pip install --no-cache-dir --upgrade pip



# Step 1: Core Framework

RUN pip install --no-cache-dir fastapi "uvicorn[standard]" python-multipart python-dotenv pydantic "pydantic-settings" email-validator motor "passlib[bcrypt]" PyJWT google-generativeai spacy && \

    python -m spacy download en_core_web_sm



# Step 2: Heavy ML Engines (CPU Only)

RUN pip install --no-cache-dir torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cpu



# Ensure any optional native extensions that might pull CUDA builds use the

# CPU wheels instead. TorchCodec can auto-pick a CUDA wheel which then tries

# to load libnvrtc (missing on CPU-only Spaces). Force-install the CPU wheel

# from the PyTorch CPU index to avoid libnvrtc dependency.

RUN pip install --no-cache-dir --force-reinstall --no-deps --index-url https://download.pytorch.org/whl/cpu torchcodec || true



# Step 3: Transformers & Scipy

RUN pip install --no-cache-dir transformers accelerate "sentence-transformers" scikit-learn numpy scipy



# Step 4: Image & Audio Utilities

RUN pip install --no-cache-dir Pillow piexif opencv-python-headless "soundfile>=0.12.0" "librosa>=0.10.0" "resampy>=0.4.2"



# Step 5: Isolate Pyannote (Very Heavy)

RUN pip install --no-cache-dir "pyannote.audio>=3.1.0"



# Step 6: Isolate C2PA (Might need build tools)

RUN pip install --no-cache-dir c2pa-python



# Step 7: Final Misc

RUN pip install --no-cache-dir "protobuf~=4.25.3" python-magic email-validator aiosmtplib



# Step 8: Extra ML Engines & Libraries

RUN pip install --no-cache-dir "optimum[onnxruntime]" diffusers mediapipe asyncpg reportlab sentencepiece openai-whisper



# Step 9: Retina-Face (Isolated to prevent OpenCV dependency conflicts)

RUN pip install --no-cache-dir retina-face --no-deps



COPY backend/ .



EXPOSE 7860



CMD ["python", "start_backend.py"]