bake sentence transformer model into Docker image to fix init network error
Browse filesSentenceTransformer('all-MiniLM-L6-v2') was downloading at runtime during
startup, failing because HF Spaces containers can't reach huggingface.co
during the init phase. Pre-downloading at build time avoids the network call.
Made-with: Cursor
- Dockerfile +4 -0
Dockerfile
CHANGED
|
@@ -26,6 +26,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 26 |
COPY backend/requirements.txt .
|
| 27 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# Copy backend
|
| 30 |
COPY --chown=user backend/ /app/backend/
|
| 31 |
|
|
|
|
| 26 |
COPY backend/requirements.txt .
|
| 27 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
+
# Pre-download the sentence transformer model into the image
|
| 30 |
+
# so startup doesn't require network access to huggingface.co
|
| 31 |
+
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
|
| 32 |
+
|
| 33 |
# Copy backend
|
| 34 |
COPY --chown=user backend/ /app/backend/
|
| 35 |
|