Spaces:
Sleeping
Sleeping
Arseniy Savin commited on
Commit ·
8feef52
1
Parent(s): 06664bd
Enhance Dockerfile for Whisper.cpp application
Browse filesUpdated the Dockerfile to include a stable cache path for user data and pre-download the Whisper.cpp model during the build process. This ensures the model is baked into the image, improving efficiency by avoiding re-downloads at container start.
- Dockerfile +13 -2
Dockerfile
CHANGED
|
@@ -20,9 +20,20 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
|
| 20 |
COPY --chown=user . .
|
| 21 |
USER user
|
| 22 |
|
| 23 |
-
# Default env tuned for CPU Basic
|
| 24 |
ENV WHISPER_MODEL=tiny.en \
|
| 25 |
-
WHISPER_THREADS=4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 28 |
|
|
|
|
| 20 |
COPY --chown=user . .
|
| 21 |
USER user
|
| 22 |
|
| 23 |
+
# Default env tuned for CPU Basic and a stable cache path
|
| 24 |
ENV WHISPER_MODEL=tiny.en \
|
| 25 |
+
WHISPER_THREADS=4 \
|
| 26 |
+
XDG_DATA_HOME=/home/user/.local/share
|
| 27 |
+
|
| 28 |
+
# Pre-download the whisper.cpp model at build time so it is baked into the image
|
| 29 |
+
# and won't be re-downloaded on each container start
|
| 30 |
+
RUN python - <<'PY'
|
| 31 |
+
import os
|
| 32 |
+
from pywhispercpp.model import Model
|
| 33 |
+
model = os.environ.get('WHISPER_MODEL','tiny.en')
|
| 34 |
+
print(f"Pre-fetching pywhispercpp model: {model}")
|
| 35 |
+
Model(model)
|
| 36 |
+
PY
|
| 37 |
|
| 38 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 39 |
|