Kelvin-programmer/rag-chatbot
0
1# ---------- build stage ----------2FROM python:3.11-slim AS builder3 4WORKDIR /app5COPY requirements.txt .6RUN pip install --no-cache-dir --prefix=/install -r requirements.txt7 8# ---------- runtime stage ----------9FROM python:3.11-slim10 11WORKDIR /app12 13COPY --from=builder /install /usr/local14COPY src/ src/15COPY pyproject.toml .16 17RUN mkdir -p data/vector_store18 19# Pin HuggingFace cache to a writable directory inside the image20ENV HF_HOME=/app/.cache/huggingface21ENV TRANSFORMERS_CACHE=/app/.cache/huggingface22 23# Pre-download models at build time so startup is instant (no timeout)24RUN python -c "\25from sentence_transformers import SentenceTransformer; \26SentenceTransformer('all-MiniLM-L12-v2'); \27print('Embedding model ready')"28 29RUN python -c "\30from transformers import AutoTokenizer, AutoModelForSeq2SeqLM; \31AutoTokenizer.from_pretrained('google/flan-t5-small'); \32AutoModelForSeq2SeqLM.from_pretrained('google/flan-t5-small'); \33print('LLM ready')"34 35EXPOSE 786036 37HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \38 CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/api/v1/health')"39 40CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "7860"]41 