# Utilisation d'une image stable avec support GPU
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04

# Configuration environnement
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app

# Installation des dépendances système (Audio + Python 3.11)
RUN apt-get update && apt-get install -y \
    python3.11 \
    python3-pip \
    ffmpeg \
    libsndfile1 \
    git \
    && rm -rf /var/lib/apt/lists/*

# Mise à jour de pip pour éviter les avertissements
RUN python3.11 -m pip install --upgrade pip

# 1. Installer PyTorch avec le lien direct CUDA 12.1
# On utilise "python3.11 -m pip" pour garantir que Gradio sera trouvé par Python 3.11
RUN python3.11 -m pip install --no-cache-dir \
    torch torchvision torchaudio \
    --index-url https://download.pytorch.org/whl/cu121

# 2. Installer le reste des dépendances
RUN python3.11 -m pip install --no-cache-dir \
    fastapi \
    uvicorn \
    gradio \
    faster-whisper

# Copie du code serveur (sera écrasé par le volume en dev, mais utile pour le build)
COPY server.py .

# Exposition du port Gradio
EXPOSE 7860

# Lancement explicite avec Python 3.11
CMD ["python3.11", "server.py"]