dernier / Dockerfile
FABLESLIP's picture
Update Dockerfile
2b33875 verified
# bump: 2025-08-22 17:xx (test logs)
# Image Python légère et récente
FROM python:3.11-slim
# Force rebuild (change la valeur quand on veut relancer)
ENV FORCE_REBUILD=2025-08-22-17h12
# (1) Dépendances système (FFmpeg + libs utiles à opencv-python-headless)
# + libgl1 pour éviter les erreurs libGL.so.1 (même en headless)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ffmpeg \
libglib2.0-0 \
libgomp1 \
libgl1 \
wget \
git \
unzip \
&& rm -rf /var/lib/apt/lists/*
# (2) Dossier de travail
WORKDIR /app
# Caches Hugging Face (cohérents et propres sous /home/user)
ENV HF_HOME=/home/user/.cache/huggingface
ENV TRANSFORMERS_CACHE=/home/user/.cache/huggingface/transformers
ENV HUGGINGFACE_HUB_CACHE=/home/user/.cache/huggingface
# (3) Installer dépendances Python
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r /app/requirements.txt
# (4) Utilisateur non-root + droits d’écriture
RUN useradd -m -u 1000 user \
&& mkdir -p /app/data/_thumbs /app/data/_masks \
&& chown -R user:user /app
USER user
ENV PATH="/home/user/.local/bin:${PATH}"
# (5) Copier le code du repo (pas seulement app.py)
COPY --chown=user:user . /app
# (6) Exposer le port attendu par Spaces et lancer Uvicorn sur $PORT
ENV PORT=7860
EXPOSE 7860
CMD ["bash","-lc","uvicorn app:app --host 0.0.0.0 --port ${PORT}"]