# Nolan en ligne sur Hugging Face Spaces (gratuit : 2 processeurs, 16 Go de mémoire, sans carte bancaire).
FROM ollama/ollama:latest

RUN apt-get update && apt-get install -y --no-install-recommends python3 && rm -rf /var/lib/apt/lists/*

# Hugging Face lance le conteneur avec l'utilisateur 1000 : tout doit être lisible et modifiable par lui.
ENV OLLAMA_MODELS=/opt/modeles \
    OLLAMA_HOST=127.0.0.1:11434 \
    OLLAMA_KEEP_ALIVE=-1 \
    HOME=/tmp \
    PORT=7860 \
    NOLAN_MODELE=gemma3:4b \
    NOLAN_LONGUEUR=300 \
    NOLAN_LANCER_OLLAMA=1

# L'IA est téléchargée une seule fois, pendant la construction (≈ 3,3 Go).
RUN mkdir -p /opt/modeles && (ollama serve > /dev/null 2>&1 &) && sleep 10 \
    && ollama pull gemma3:4b && chmod -R 777 /opt/modeles

COPY nolan-nuage.py /app/nolan-nuage.py
EXPOSE 7860
ENTRYPOINT ["python3", "-u", "/app/nolan-nuage.py"]
