File size: 1,584 Bytes
3be54c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
46
47
48
# Multi-stage Dockerfile for tau-rag
# ---------------------------------------------------------------------------
# STAGE 1: base — slim Python + minimal deps (runs mock + extractive).
# STAGE 2: full — adds torch, faiss, sentence-transformers (AlephBERT).
#
# Usage:
#   docker build -t tau-rag:slim --target slim .
#   docker build -t tau-rag:full --target full .
#   docker run -p 8000:8000 tau-rag:slim
# ---------------------------------------------------------------------------

FROM python:3.11-slim AS slim

WORKDIR /app

# Only what we need for the zero-dep pipeline + FastAPI
COPY pyproject.toml /app/
COPY . /app/tau_rag

RUN pip install --no-cache-dir \
    "pydantic>=2.6" \
    "rank-bm25>=0.2.2" \
    "numpy>=1.26" \
    "fastapi>=0.111" \
    "uvicorn[standard]>=0.29" \
    "pypdf>=3.0"

ENV PYTHONPATH=/app
EXPOSE 8000
CMD ["uvicorn", "tau_rag.api.fastapi_app:app", \
     "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]

# ---------------------------------------------------------------------------
FROM slim AS full
# Adds AlephBERT + FAISS — ~3GB image but real semantic retrieval.
RUN pip install --no-cache-dir \
    "torch>=2.0" \
    "transformers>=4.40" \
    "sentence-transformers>=2.6" \
    "faiss-cpu>=1.8"

# Pre-warm AlephBERT so cold-start at runtime is just a memmap open.
RUN python -c "from tau_rag.core.embedders import make_transformers_embedder; \
    make_transformers_embedder('onlplab/alephbert-base')" || true

CMD ["uvicorn", "tau_rag.api.fastapi_app:app", \
     "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]