Spaces:
Sleeping
Sleeping
| FROM python:3.10-slim | |
| # 1. Dossier temporaire de build et variables d'environnement | |
| WORKDIR /app | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| CMAKE_BUILD_PARALLEL_LEVEL=1 \ | |
| MAKEFLAGS="-j1" | |
| # 2. Installation des outils système (en tant que root) | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| cmake \ | |
| git \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 3. Installation globale des packages Python (en tant que root) | |
| # Plus besoin de --user, c'est ultra-stable et isolé dans le conteneur | |
| RUN pip install --no-cache-dir fastapi uvicorn huggingface_hub pydantic | |
| RUN pip install --no-cache-dir llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu | |
| # 4. Création de l'utilisateur requis par Hugging Face (UID 1000) | |
| RUN useradd -m -u 1000 user | |
| # 5. Configuration de son espace de travail | |
| WORKDIR /home/user/app | |
| # 6. Copie du code en lui attribuant directement la propriété des fichiers | |
| COPY --chown=user:user . . | |
| # 7. Passage sous l'utilisateur non-privilégié pour l'exécution | |
| USER user | |
| # Port Hugging Face | |
| EXPOSE 7860 | |
| # Lancement de l'API | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |