Sara-Adjo commited on
Commit
32e3908
Β·
verified Β·
1 Parent(s): 96d6137

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -8
Dockerfile CHANGED
@@ -1,18 +1,48 @@
 
1
  FROM python:3.10-slim
2
 
 
3
  WORKDIR /app
4
 
5
- COPY requirements.txt .
6
-
7
- RUN pip install --no-cache-dir flask pillow numpy gunicorn
8
- RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
9
- RUN pip install --no-cache-dir tensorflow-cpu
 
 
 
10
 
 
 
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  COPY . .
13
 
14
-
15
  EXPOSE 7860
16
 
17
-
18
- CMD ["gunicorn", "app:app", "--bind", "0.0.0.0:7860", "--timeout", "120"]
 
 
 
 
 
1
+ # ── Image de base Python ──────────────────────────────────────────────────────
2
  FROM python:3.10-slim
3
 
4
+ # ── RΓ©pertoire de travail dans le conteneur ───────────────────────────────────
5
  WORKDIR /app
6
 
7
+ # ── DΓ©pendances systΓ¨me (nΓ©cessaires pour certains packages Python) ────────────
8
+ RUN apt-get update && apt-get install -y \
9
+ libglib2.0-0 \
10
+ libsm6 \
11
+ libxext6 \
12
+ libxrender-dev \
13
+ libgomp1 \
14
+ && rm -rf /var/lib/apt/lists/*
15
 
16
+ # ── Copier requirements en premier (optimise le cache Docker) ─────────────────
17
+ COPY requirements.txt .
18
 
19
+ # ── Installer Flask et utilitaires ────────────────────────────────────────────
20
+ RUN pip install --no-cache-dir \
21
+ flask==3.0.0 \
22
+ pillow==10.0.0 \
23
+ numpy==1.24.0 \
24
+ gunicorn==21.2.0
25
+
26
+ # ── Installer PyTorch CPU ──────────────────────────────────────────────────────
27
+ RUN pip install --no-cache-dir \
28
+ torch==2.1.0 \
29
+ torchvision==0.16.0 \
30
+ --index-url https://download.pytorch.org/whl/cpu
31
+
32
+ # ── Installer TensorFlow β€” VERSION FIXΓ‰E pour compatibilitΓ© .keras ────────────
33
+ # On installe la mΓͺme version que Colab pour Γ©viter les erreurs de dΓ©sΓ©rialisation
34
+ RUN pip install --no-cache-dir \
35
+ tensorflow-cpu==2.14.0
36
+
37
+ # ── Copier tous les fichiers du projet ────────────────────────────────────────
38
  COPY . .
39
 
40
+ # ── Port Hugging Face Spaces ───────────────────────────────────────────────────
41
  EXPOSE 7860
42
 
43
+ # ── Lancement avec Gunicorn ───────────────────────────────────────────────────
44
+ CMD ["gunicorn", "app:app", \
45
+ "--bind", "0.0.0.0:7860", \
46
+ "--workers", "1", \
47
+ "--timeout", "120", \
48
+ "--preload"]