File size: 1,580 Bytes
9c3b266
8a82346
 
9c3b266
8a82346
 
280cf3f
 
 
8a82346
 
9c3b266
8a82346
 
9c3b266
 
 
 
 
 
 
 
 
 
 
8a82346
 
 
 
 
 
 
9c3b266
8a82346
 
 
9c3b266
8a82346
 
9c3b266
 
 
 
 
 
 
 
8a82346
9c3b266
8a82346
 
9c3b266
 
 
 
 
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
49
50
51
52
53
54
55
56
57
# Use Python 3.10 slim image as base
FROM python:3.10-slim

# Install system dependencies
RUN apt-get update && \
    apt-get install -y \
      build-essential \
      git \
      poppler-utils \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Pre-create all runtime & cache dirs with open perms
RUN mkdir -p \
      /app/.files \
      /app/.chainlit \
      /app/.cache \
      /app/model_cache \
      /app/vectorstore/db_faiss \
      /app/data && \
    chmod -R a+rwx /app/.files /app/.chainlit /app/.cache /app/model_cache /app/vectorstore /app/data

# Environment variables
ENV PYTHONUNBUFFERED=1
ENV TRANSFORMERS_CACHE=/app/model_cache
ENV HF_HOME=/app/model_cache
ENV TORCH_HOME=/app/model_cache
ENV CHAINLIT_HOST=0.0.0.0
ENV CHAINLIT_PORT=7860

# Install Python deps
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy your application code
COPY model.py ingest.py chainlit.md download_assets.py ./

# Pre‐warm large models into the cache (so first startup is fast)
RUN python -c "\
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM; \
AutoTokenizer.from_pretrained('google/flan-t5-base'); \
AutoModelForSeq2SeqLM.from_pretrained('google/flan-t5-base'); \
from sentence_transformers import SentenceTransformer; \
SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')\
"

# Expose Chainlit’s port
EXPOSE 7860

# On container start, download your assets then launch Chainlit
CMD ["sh", "-c", "\
  python download_assets.py && \
  exec chainlit run model.py --host 0.0.0.0 --port 7860\
"]