APIRRF / Dockerfile
antonypamo's picture
Update Dockerfile
bbc1789 verified
# ======================================================
# Savant RRF Φ12.5 — Optimized Dockerfile
# ======================================================
FROM python:3.11-slim
# --------------------------
# ENV optimizations
# --------------------------
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
HF_HOME=/cache/huggingface \
TRANSFORMERS_CACHE=/cache/huggingface \
SENTENCE_TRANSFORMERS_HOME=/cache/huggingface
# --------------------------
# Workdir
# --------------------------
WORKDIR /app
# --------------------------
# System deps (minimal)
# --------------------------
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*
# --------------------------
# Install Python deps (cache-friendly)
# --------------------------
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# --------------------------
# Preload models (CRITICAL for cold start)
# --------------------------
RUN python - <<EOF
from sentence_transformers import SentenceTransformer
from huggingface_hub import hf_hub_download
# preload embedder
SentenceTransformer("antonypamo/RRFSAVANTMADE")
# preload meta-logit
hf_hub_download(
repo_id="antonypamo/RRFSavantMetaLogicV2",
filename="logreg_rrf_savant.joblib"
)
EOF
# --------------------------
# Copy app (AFTER deps for cache)
# --------------------------
COPY app.py .
# --------------------------
# Expose port
# --------------------------
EXPOSE 7860
# --------------------------
# Start server (optimized)
# --------------------------
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]