Spaces:
Sleeping
Sleeping
build: Remove build-time weight download to fix Hugging Face secret mounting error
Browse files- Dockerfile +1 -16
Dockerfile
CHANGED
|
@@ -19,22 +19,7 @@ COPY backend/ ./backend/
|
|
| 19 |
ENV PORT=7860
|
| 20 |
ENV PYTHONPATH=/app/backend
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
# HF_TOKEN must be set as a Space secret (NOT hardcoded here).
|
| 24 |
-
# In HF Space: Settings → Secrets → Add secret HF_TOKEN
|
| 25 |
-
RUN --mount=type=secret,id=HF_TOKEN \
|
| 26 |
-
HF_TOKEN=$(cat /run/secrets/HF_TOKEN 2>/dev/null || echo "") \
|
| 27 |
-
python -c "
|
| 28 |
-
import os
|
| 29 |
-
token = os.environ.get('HF_TOKEN', '')
|
| 30 |
-
if token:
|
| 31 |
-
from huggingface_hub import snapshot_download
|
| 32 |
-
print('Pre-downloading google/gemma-2-2b-it weights...')
|
| 33 |
-
snapshot_download('google/gemma-2-2b-it', token=token, ignore_patterns=['*.msgpack', '*.h5'])
|
| 34 |
-
print('Done.')
|
| 35 |
-
else:
|
| 36 |
-
print('HF_TOKEN not set — weights will be downloaded on first request.')
|
| 37 |
-
"
|
| 38 |
|
| 39 |
WORKDIR /app/backend
|
| 40 |
|
|
|
|
| 19 |
ENV PORT=7860
|
| 20 |
ENV PYTHONPATH=/app/backend
|
| 21 |
|
| 22 |
+
# Model weights are loaded and cached dynamically at runtime to keep builds fast and stable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
WORKDIR /app/backend
|
| 25 |
|