FROM nvidia/cuda:12.4.1-devel-ubuntu22.04 ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 ENV HF_HOME=/app/model_cache ENV TORCH_HOME=/app/torch_cache # Install Python 3.12 + system deps RUN apt-get update && apt-get install -y \ software-properties-common \ git \ curl \ ffmpeg \ libsndfile1 \ && add-apt-repository ppa:deadsnakes/ppa \ && apt-get update \ && apt-get install -y python3.12 python3.12-venv python3.12-dev \ && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12 \ && ln -sf /usr/bin/python3.12 /usr/bin/python \ && ln -sf /usr/bin/python3.12 /usr/bin/python3 \ && rm -rf /var/lib/apt/lists/* # Remove conflicting system packages RUN apt-get update && apt-get remove -y python3-blinker || true \ && rm -rf /usr/lib/python3/dist-packages/blinker* \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt /app/requirements.txt WORKDIR /app RUN pip install --no-cache-dir --break-system-packages -r requirements.txt # flash-attn intentionally NOT built from source here: the compile needs ~10 GB # RAM and gets OOM-killed on the HF Spaces builder, which fails the whole build # (the `|| echo` fallback can't catch an OOM kill of the build process itself). # vLLM runs fine on its default attention backend. For the ~1.5-2x speedup, # install a prebuilt wheel matching torch+CUDA+python from # https://github.com/Dao-AILab/flash-attention/releases # e.g. RUN pip install --no-build-isolation # Pre-download ASR model into the image (no persistent storage available on HF Spaces). # NOTE: single-line python -c on purpose — ACR's Dockerfile dependency scanner # chokes on backslash line-continuations inside a quoted python string. RUN mkdir -p /app/model_cache /app/torch_cache && \ python -c "from huggingface_hub import snapshot_download; snapshot_download('Qwen/Qwen3-ASR-1.7B', cache_dir='/app/model_cache')" && \ echo "ASR model pre-downloaded" # Pre-download Silero VAD model RUN python -c "import torch; torch.hub.load('snakers4/silero-vad', 'silero_vad', trust_repo=True); print('Silero VAD cached')" || echo "VAD pre-download failed, will retry at runtime" # Copy application code COPY . /app EXPOSE 7860 # Health check — long start period for model download + load HEALTHCHECK --interval=30s --timeout=30s --start-period=600s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 CMD ["python", "main_async.py"] # Rebuild trigger: Wed Apr 22 18:13:56 PKT 2026