midah commited on
Commit
d64a26f
·
1 Parent(s): da2430e

bake sentence transformer model into Docker image to fix init network error

Browse files

SentenceTransformer('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

Files changed (1) hide show
  1. 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