KJ24's picture
Upload 9 files
26b23e3 verified
# Dockerfile pour Smart Chunker API v4.0
# Compatible HuggingFace Spaces + Pipeline complet
# Version finale corrigée
# ===================================
# IMAGE DE BASE OPTIMISÉE
# ===================================
FROM python:3.10-slim
# ===================================
# MÉTADONNÉES
# ===================================
LABEL maintainer="Smart Chunker Pipeline v4.0"
LABEL description="API de chunking sémantique intelligent récursif"
LABEL version="4.0.0"
# ===================================
# VARIABLES D'ENVIRONNEMENT
# ===================================
# Configuration Python
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONIOENCODING=utf-8
# Configuration HuggingFace pour Spaces
ENV HF_HOME=/tmp/huggingface
ENV TRANSFORMERS_CACHE=/tmp/transformers
ENV HF_HUB_CACHE=/tmp/hub
ENV TOKENIZERS_PARALLELISM=false
ENV HF_HUB_DISABLE_PROGRESS_BARS=1
ENV TRANSFORMERS_VERBOSITY=error
# Configuration FastAPI/Uvicorn
ENV PORT=7860
ENV HOST=0.0.0.0
ENV WORKERS=1
# Optimisations performance
ENV OMP_NUM_THREADS=1
ENV OPENBLAS_NUM_THREADS=1
ENV MKL_NUM_THREADS=1
# ===================================
# INSTALLATION DÉPENDANCES SYSTÈME
# ===================================
RUN apt-get update && apt-get install -y \
build-essential \
git \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# ===================================
# CRÉATION RÉPERTOIRE TRAVAIL
# ===================================
WORKDIR /app
# ===================================
# CRÉATION DOSSIERS CACHE
# ===================================
RUN mkdir -p /tmp/huggingface \
&& mkdir -p /tmp/transformers \
&& mkdir -p /tmp/hub \
&& mkdir -p /tmp/llm \
&& mkdir -p /tmp/embeddings \
&& mkdir -p /tmp/logs \
&& chmod -R 755 /tmp
# ===================================
# COPIE FICHIERS CONFIGURATION
# ===================================
# Copie requirements en premier pour cache Docker
COPY requirements.txt .
# ===================================
# INSTALLATION DÉPENDANCES PYTHON
# ===================================
# Mise à jour pip
RUN pip install --no-cache-dir --upgrade pip
# Installation des dépendances avec cache nettoyé
RUN rm -rf /root/.cache/pip \
&& pip install --no-cache-dir -r requirements.txt
# ===================================
# COPIE CODE APPLICATION
# ===================================
# Copie tous les fichiers Python
COPY *.py .
COPY config.yaml .
# ===================================
# CONFIGURATION PERMISSIONS
# ===================================
# S'assurer que les dossiers sont accessibles
RUN chmod -R 755 /app \
&& chmod -R 777 /tmp
# ===================================
# VÉRIFICATION SANTÉ
# ===================================
# Healthcheck pour vérifier que l'API répond
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
# ===================================
# EXPOSITION PORT
# ===================================
EXPOSE ${PORT}
# ===================================
# COMMANDE DE DÉMARRAGE
# ===================================
# Commande par défaut pour démarrer l'application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]