From cba27fc728aef107d48495130fac8bab20094960 Mon Sep 17 00:00:00 2001 From: Lucas Winther Date: Tue, 14 Jul 2026 21:51:42 +0200 Subject: [PATCH] Preload server-side models. --- Dockerfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ca147be..8799e23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,12 +77,16 @@ RUN python3 -m venv /opt/faster-whisper \ && /opt/faster-whisper/bin/pip install --no-cache-dir -r server-py/requirements.txt ENV SIDECAR_PYTHON=/opt/faster-whisper/bin/python3 -# Cache Whisper weights inside the data volume so a container restart does not -# re-download them (first request per model downloads from the HF Hub). -ENV FASTER_WHISPER_DOWNLOAD_ROOT=/app/data/faster-whisper-models +# Cache Whisper weights inside the image (outside the /app/data volume) +# so they are not shadowed by bind mounts and don't need to be downloaded at runtime. +ENV FASTER_WHISPER_DOWNLOAD_ROOT=/opt/faster-whisper/models +RUN mkdir -p /opt/faster-whisper/models && chown -R bun:bun /opt/faster-whisper/models USER bun +# Pre-download the allowed models (large-v3-turbo and medium.en) +RUN $SIDECAR_PYTHON -c "import faster_whisper; faster_whisper.download_model('large-v3-turbo', cache_dir='/opt/faster-whisper/models'); faster_whisper.download_model('medium.en', cache_dir='/opt/faster-whisper/models')" + # --------------------------------------------------------------------------- # Default target: a plain `docker build .` (what .gitlab-ci.yml runs) must # produce the Bun-only image, but Docker builds the *last* stage by default