FROM python:3.10-slim RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ git \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install PyTorch CPU-only first (saves ~1.5GB vs full CUDA version) RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir torch torchaudio --index-url https://download.pytorch.org/whl/cpu COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app COPY --chown=user . $HOME/app # Pre-cache the Whisper 'base' model RUN python -c "from faster_whisper import WhisperModel; WhisperModel('base', device='cpu', compute_type='int8')" # Pre-download the NAMAA TTS model weights RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='NAMAA-Space/NAMAA-Egyptian-TTS', repo_type='model', revision='main')" EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]