antonypamo commited on
Commit
bbc1789
·
verified ·
1 Parent(s): 6df19e8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +51 -16
Dockerfile CHANGED
@@ -1,33 +1,68 @@
1
- # ============================
2
- # Dockerfile – Savant RRF Φ12.0 API
3
- # ============================
 
4
  FROM python:3.11-slim
5
 
6
- # Evitar pyc y usar stdout sin buffer
7
- ENV PYTHONDONTWRITEBYTECODE=1
8
- ENV PYTHONUNBUFFERED=1
 
 
 
 
 
 
9
 
10
- # Directorio de trabajo
 
 
11
  WORKDIR /app
12
 
13
- # Dependencias del sistema (para numpy/scipy)
 
 
14
  RUN apt-get update && apt-get install -y --no-install-recommends \
15
  build-essential \
16
  git \
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
- # Copiar requirements e instalarlos
20
- COPY requirements.txt /app/requirements.txt
 
 
21
 
22
  RUN pip install --upgrade pip && \
23
  pip install --no-cache-dir -r requirements.txt
24
 
25
- # Copiar el código de la API
26
- COPY app.py /app/app.py
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- # Puerto por defecto de Hugging Face Spaces para FastAPI
 
 
29
  EXPOSE 7860
30
 
31
- # Comando de arranque
32
- # Nota: host 0.0.0.0 para que sea accesible desde fuera del contenedor
33
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
+ # ======================================================
2
+ # Savant RRF Φ12.5 — Optimized Dockerfile
3
+ # ======================================================
4
+
5
  FROM python:3.11-slim
6
 
7
+ # --------------------------
8
+ # ENV optimizations
9
+ # --------------------------
10
+ ENV PYTHONDONTWRITEBYTECODE=1 \
11
+ PYTHONUNBUFFERED=1 \
12
+ PIP_NO_CACHE_DIR=1 \
13
+ HF_HOME=/cache/huggingface \
14
+ TRANSFORMERS_CACHE=/cache/huggingface \
15
+ SENTENCE_TRANSFORMERS_HOME=/cache/huggingface
16
 
17
+ # --------------------------
18
+ # Workdir
19
+ # --------------------------
20
  WORKDIR /app
21
 
22
+ # --------------------------
23
+ # System deps (minimal)
24
+ # --------------------------
25
  RUN apt-get update && apt-get install -y --no-install-recommends \
26
  build-essential \
27
  git \
28
  && rm -rf /var/lib/apt/lists/*
29
 
30
+ # --------------------------
31
+ # Install Python deps (cache-friendly)
32
+ # --------------------------
33
+ COPY requirements.txt .
34
 
35
  RUN pip install --upgrade pip && \
36
  pip install --no-cache-dir -r requirements.txt
37
 
38
+ # --------------------------
39
+ # Preload models (CRITICAL for cold start)
40
+ # --------------------------
41
+ RUN python - <<EOF
42
+ from sentence_transformers import SentenceTransformer
43
+ from huggingface_hub import hf_hub_download
44
+
45
+ # preload embedder
46
+ SentenceTransformer("antonypamo/RRFSAVANTMADE")
47
+
48
+ # preload meta-logit
49
+ hf_hub_download(
50
+ repo_id="antonypamo/RRFSavantMetaLogicV2",
51
+ filename="logreg_rrf_savant.joblib"
52
+ )
53
+ EOF
54
+
55
+ # --------------------------
56
+ # Copy app (AFTER deps for cache)
57
+ # --------------------------
58
+ COPY app.py .
59
 
60
+ # --------------------------
61
+ # Expose port
62
+ # --------------------------
63
  EXPOSE 7860
64
 
65
+ # --------------------------
66
+ # Start server (optimized)
67
+ # --------------------------
68
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]