File size: 1,053 Bytes
4ecd4b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_DEFAULT_TIMEOUT=600 \
    HF_HOME=/app/.cache \
    TRANSFORMERS_CACHE=/app/.cache \
    HUGGINGFACE_HUB_CACHE=/app/.cache

WORKDIR /app

# Outils utiles
RUN apt-get update && apt-get install -y --no-install-recommends git \
    && rm -rf /var/lib/apt/lists/*

# Pip à jour
RUN pip install --no-cache-dir --upgrade pip setuptools wheel

# ⚠️ Torch CPU depuis l'index officiel PyTorch (fiable)
RUN pip --retries 5 --default-timeout=600 install --no-cache-dir \
    torch==2.3.1+cpu \
    -f https://download.pytorch.org/whl/torch_stable.html

# Dépendances restantes (sans torch dans requirements.txt)
COPY requirements.txt .
RUN pip --retries 5 --default-timeout=600 install --no-cache-dir -r requirements.txt

# ✅ Crée le dossier cache et donne les droits
RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache

# Code
COPY . .

# Port attendu par Hugging Face Spaces (Docker)
EXPOSE 7860
CMD ["uvicorn", "app.main:app", "--host","0.0.0.0","--port","7860"]