KJ24 commited on
Commit
e14f7dd
·
verified ·
1 Parent(s): 3ba134a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +47 -22
Dockerfile CHANGED
@@ -1,34 +1,59 @@
1
- # 📦 Image de base Python 3.10
2
- FROM python:3.10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- # Installer les outils système nécessaires à llama-cpp et transformers
5
- RUN apt-get update && apt-get install -y \
6
  build-essential \
7
- cmake \
8
  git \
9
- && rm -rf /var/lib/apt/lists/*
 
 
 
10
 
11
- # Configuration du cache HF dans un dossier autorisé
12
- ENV HF_HOME=/app/cache \
13
- TRANSFORMERS_CACHE=/app/cache \
14
- HF_MODULES_CACHE=/app/cache \
15
- HF_HUB_CACHE=/app/cache
16
 
17
- # Création du dossier cache avec accès complet
18
- RUN mkdir -p /app/cache && chmod -R 777 /app/cache
19
 
20
- # 📁 Dossier de travail dans le conteneur
21
- WORKDIR /app
22
 
23
- # 🧪 Installer les dépendances Python en premier
24
- COPY requirements.txt .
25
- RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
26
 
27
- # 🧠 Copier le code de l’application (ex: app.py)
28
- COPY . .
29
 
30
- # 🌐 Exposer le port HTTP pour l’API FastAPI
31
  EXPOSE 7860
32
 
33
- # 🚀 Commande de démarrage du serveur Uvicorn
34
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # ================================================================
2
+ # 🐳 Dockerfile - Hugging Face Space (SDK Docker)
3
+ # ================================================================
4
+ # Objectif : API FastAPI + Chunking sémantique intelligent
5
+ # Compatible : HF Space gratuit (2GB RAM, CPU only)
6
+ # Port requis : 7860 (imposé par Hugging Face)
7
+ # ================================================================
8
+
9
+ # ===== BASE IMAGE LÉGÈRE =====
10
+ FROM python:3.10-slim
11
+
12
+ # ===== VARIABLES D'ENVIRONNEMENT OPTIMISÉES =====
13
+ ENV PYTHONUNBUFFERED=1
14
+ ENV PYTHONDONTWRITEBYTECODE=1
15
+ ENV PIP_NO_CACHE_DIR=1
16
+ ENV PIP_DISABLE_PIP_VERSION_CHECK=1
17
+
18
+ # ✅ Configuration cache HuggingFace pour Space gratuit
19
+ ENV HF_HOME=/app/cache/huggingface
20
+ ENV TRANSFORMERS_CACHE=/app/cache/transformers
21
+ ENV HF_HUB_CACHE=/app/cache/hub
22
+ ENV TOKENIZERS_PARALLELISM=false
23
+ ENV HF_HUB_DISABLE_PROGRESS_BARS=1
24
+
25
+ # ===== RÉPERTOIRE DE TRAVAIL =====
26
+ WORKDIR /app
27
 
28
+ # ===== INSTALLATION DÉPENDANCES SYSTÈME MINIMALES =====
29
+ RUN apt-get update && apt-get install -y --no-install-recommends \
30
  build-essential \
 
31
  git \
32
+ curl \
33
+ && rm -rf /var/lib/apt/lists/* \
34
+ && rm -rf /tmp/* \
35
+ && rm -rf /var/tmp/*
36
 
37
+ # ===== CRÉATION DOSSIERS CACHE =====
38
+ RUN mkdir -p /app/cache/huggingface \
39
+ && mkdir -p /app/cache/transformers \
40
+ && mkdir -p /app/cache/hub \
41
+ && chmod -R 755 /app/cache
42
 
43
+ # ===== COPIE FICHIERS PROJECT =====
44
+ COPY . /app
45
 
46
+ # ===== MISE À JOUR PIP =====
47
+ RUN pip install --upgrade pip
48
 
49
+ # ===== INSTALLATION DÉPENDANCES =====
50
+ RUN pip install -r requirements.txt
 
51
 
52
+ # PATCH SÉCURITÉ : Réinstaller uvicorn explicitement
53
+ RUN pip install uvicorn
54
 
55
+ # ===== EXPOSITION DU PORT =====
56
  EXPOSE 7860
57
 
58
+ # ===== COMMANDE DE LANCEMENT =====
59
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]