File size: 2,123 Bytes
82d7501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
620578c
 
 
82d7501
 
 
 
 
 
 
 
 
 
 
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
# TrueScan - GPU server (Hugging Face Spaces GPU, RunPod, any NVIDIA host).
# The PyPI torch wheel for Linux already bundles the CUDA runtime; the host
# only needs an NVIDIA driver (all GPU clouds provide it).
FROM python:3.11-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential g++ libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 \
        ffmpeg libsndfile1 git curl \
    && rm -rf /var/lib/apt/lists/*

RUN useradd -m -u 1000 user
ENV HOME=/home/user \
    PIP_NO_CACHE_DIR=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    HF_HOME=/home/user/cache/huggingface \
    TORCH_HOME=/home/user/cache/torch \
    XDG_CACHE_HOME=/home/user/cache \
    YOLO_CONFIG_DIR=/home/user/cache/ultralytics \
    MPLCONFIGDIR=/home/user/cache/matplotlib \
    EASYOCR_MODULE_PATH=/home/user/cache/easyocr \
    HF_HUB_DISABLE_SYMLINKS_WARNING=1 \
    PYTHONUNBUFFERED=1 \
    TRUESCAN_SERVER=1 \
    TRUESCAN_PARALLEL=2 \
    PORT=7860

# CUDA 12.8 build: runs on any recent NVIDIA driver (>= 570). Falls back to
# the default PyPI build if that index is unreachable.
RUN pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128 \
 || pip install torch torchvision
# onnxruntime stays the CPU build on purpose (only insightface uses it; the
# GPU build conflicts with it and depends on a matching CUDA version).
COPY --chown=user server/requirements-server.txt /tmp/req.txt
RUN pip install -r /tmp/req.txt \
 && pip install webrtcvad-wheels \
 && pip install --no-deps resemblyzer \
 && pip install --no-deps "photoholmes @ git+https://github.com/photoholmes/photoholmes" \
 && pip install pydantic pyyaml scikit-image mpmath torchmetrics torch_kmeans typing_extensions \
 && (pip install jpegio || echo "jpegio unavailable") \
 && pip uninstall -y opencv-python \
 && pip install --force-reinstall --no-deps opencv-python-headless

WORKDIR /home/user/app
COPY --chown=user . /home/user/app
ENV PYTHONPATH=/home/user/app:/home/user/app/route:/home/user/app/models
RUN mkdir -p /home/user/cache && chown -R user /home/user

USER user
EXPOSE 7860
CMD ["python", "app.py"]