File size: 1,529 Bytes
4661ac1 6c516b6 4661ac1 6c516b6 4661ac1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | FROM python:3.11-slim
WORKDIR /app
# Install system dependencies + redis-server for sidecar
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
git \
build-essential \
redis-server \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
# torch CPU FIRST (the PyPI default wheel is the CUDA build, ~2.5 GB) — the
# risk-scorer and advisory layers run on PyTorch (the ONNX export was unreliable).
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Part B Change 4 — persistent local-model cache.
# Model weights are downloaded ONCE at build time from the public HF Hub
# (free, unmetered — Hub downloads are NOT Inference API calls) into
# /app/models, and HF_HOME points there for the runtime. A running container
# therefore makes ZERO network calls for scoring: no Inference API, no token,
# no credits. If AI_SCORER_MODEL is changed at runtime without a rebuild, the
# pipeline transparently downloads the new checkpoint on first use.
ENV HF_HOME=/app/models
RUN python3 -c "from transformers import pipeline; pipeline('zero-shot-classification', model='typeform/distilbert-base-uncased-mnli', device=-1)" \
&& echo "[BUILD] local scorer checkpoint baked into image"
# Copy app source AND entrypoint
COPY app/ ./app/
COPY entrypoint.py .
EXPOSE 7860
# Use the entrypoint that starts redis + celery worker + uvicorn
CMD ["python3", "entrypoint.py"]
|