File size: 1,869 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 | # TrueScan - online test server (Hugging Face Spaces / any Docker host).
# Python and every library are installed INSIDE this image on the server's
# side - nothing is downloaded to your PC.
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/*
# Hugging Face Spaces runs the app as user 1000
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 \
PORT=7860
# CPU-only torch (much smaller than the default CUDA build)
RUN pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
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"]
|