File size: 1,435 Bytes
c917187 1932190 c917187 2b33875 1932190 2b33875 9142659 1932190 2b33875 9142659 2b33875 9142659 1932190 c917187 1932190 2b33875 |
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 |
# 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}"]
|