TARGET_SPACE / Dockerfile
RDS777's picture
Upload 62 files
7dcbd04 verified
Raw History Blame Contribute Delete
978 Bytes
# Hugging Face Space (SDK docker). Variante CPU par défaut ; GPU : --build-arg TORCH_VARIANT=gpu
FROM python:3.12-slim
ARG TORCH_VARIANT=cpu
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PORT=7860 \
MOUH_DATA_DIR=/home/user/data \
HOME=/home/user
# Utilisateur non-root (exigé par les Spaces) : l'isolation des skills repose sur ce conteneur
RUN useradd -m -u 1000 user
WORKDIR /home/user/app
COPY --chown=user requirements.txt requirements-dev.txt ./
RUN if [ "$TORCH_VARIANT" = "cpu" ]; then \
pip install --index-url https://download.pytorch.org/whl/cpu torch ; \
else \
pip install torch triton ; \
fi \
&& pip install -r requirements.txt
COPY --chown=user . .
USER user
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s CMD python -c "import urllib.request,os;urllib.request.urlopen('http://127.0.0.1:'+os.environ.get('PORT','7860'))" || exit 1
CMD ["python", "app.py"]