clustering-test / Dockerfile
xxmaranxx's picture
Update Dockerfile
a7965d0 verified
FROM python:3.10-slim
# --- Configuraci贸n general y optimizaci贸n CPU ---
ENV HF_HUB_DISABLE_TELEMETRY=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
TOKENIZERS_PARALLELISM=false \
OMP_NUM_THREADS=1 \
MKL_NUM_THREADS=1
WORKDIR /app
# --- Dependencias ---
COPY requirements.txt .
RUN pip install --upgrade pip setuptools wheel \
&& pip install -r requirements.txt
# --- Copiamos el c贸digo y modelos ---
COPY . .
# --- Warmup: descarga y cachea modelos en build ---
RUN python - <<'PY'
import pickle
from transformers import pipeline
from sentence_transformers import SentenceTransformer
print("Warmup: inicializando modelos...")
# Sentimiento (siempre existe)
pipeline('text-classification', model='UMUTeam/roberta-spanish-sentiment-analysis', device=-1)('hola')
# SBERT (solo si predictor.pkl existe)
try:
lw = pickle.load(open('predictor.pkl','rb'))
SentenceTransformer(lw['model_name']).encode('hola')
print("Warmup SBERT completo.")
except Exception as e:
print("Warmup SBERT omitido:", e)
PY
# --- Exposici贸n del servicio ---
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]