File size: 1,098 Bytes
f390b04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1 \
    HF_HOME=/app/.cache \
    TRANSFORMERS_CACHE=/app/.cache \
    CONV_DB_PATH=/tmp/conversation_logs.db

WORKDIR /app

# System dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    git curl build-essential \
    && rm -rf /var/lib/apt/lists/*

# Python dependencies
COPY requirements.txt ./
RUN pip install --upgrade pip && pip install -r requirements.txt

# spaCy model required by Presidio for name/location detection
RUN python -m spacy download en_core_web_lg

# Pre-download the Hugging Face models at build time so the first request is fast.
# (Comment out to download lazily on first use instead.)
RUN python - <<'PY'
from transformers import pipeline
pipeline("token-classification", model="dslim/bert-base-NER", aggregation_strategy="simple")
pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
print("Models cached.")
PY

# Application code
COPY . .

EXPOSE 8000

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]