addgbf commited on
Commit
9fc4cdd
·
1 Parent(s): 4958ab0

Fix cache perms + port 7860 for HF Spaces

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -1
Dockerfile CHANGED
@@ -6,6 +6,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
6
 
7
  WORKDIR /app
8
 
 
 
 
 
 
 
 
 
9
  COPY requirements.txt ./
10
  RUN pip install --upgrade pip && pip install -r requirements.txt
11
 
@@ -13,5 +21,12 @@ COPY server1.py .
13
  COPY text_embeddings_h14.pt .
14
  COPY text_embeddings_modelos_h14.pt .
15
 
16
- # Hugging Face Spaces exige escuchar en el puerto 7860
 
 
 
 
 
 
 
17
  CMD ["python", "-m", "uvicorn", "server1:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
 
6
 
7
  WORKDIR /app
8
 
9
+ # === caches escribibles dentro de /app ===
10
+ ENV HF_HOME=/app/.cache \
11
+ HF_HUB_CACHE=/app/.cache \
12
+ XDG_CACHE_HOME=/app/.cache \
13
+ OPENCLIP_CACHE_DIR=/app/.cache \
14
+ TORCH_HOME=/app/.cache/torch
15
+ RUN mkdir -p /app/.cache /app/.cache/torch
16
+
17
  COPY requirements.txt ./
18
  RUN pip install --upgrade pip && pip install -r requirements.txt
19
 
 
21
  COPY text_embeddings_h14.pt .
22
  COPY text_embeddings_modelos_h14.pt .
23
 
24
+ # (OPCIONAL) pre-descargar los pesos durante el build para evitar descarga en runtime
25
+ RUN python - <<'PY'
26
+ import open_clip
27
+ open_clip.create_model_and_transforms('ViT-H-14', pretrained='laion2b_s32b_b79k', cache_dir="/app/.cache")
28
+ print("Pesos cacheados en /app/.cache")
29
+ PY
30
+
31
+ # En Spaces debes escuchar en 7860
32
  CMD ["python", "-m", "uvicorn", "server1:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]