File size: 1,375 Bytes
ea9b39e
022f5f2
d3c2b88
022f5f2
 
d3c2b88
022f5f2
0e4a6e3
 
d3c2b88
 
022f5f2
d3c2b88
6664b36
 
 
ea9b39e
0e4a6e3
 
 
ed55f45
d3c2b88
ed55f45
022f5f2
d3c2b88
0e4a6e3
 
 
d3c2b88
 
 
 
ea9b39e
ed55f45
 
0e4a6e3
074b1bb
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
# Use lightweight python 3.9 image
FROM python:3.9-slim

WORKDIR /app

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

# Set Hugging Face cache path
ENV HF_HOME=/app/model_cache
ENV STREAMLIT_CONFIG_DIR=/app/.streamlit

# Copy files
COPY requirements.txt ./
COPY .streamlit/ .streamlit/
COPY src/ ./src/

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

# Create cache and config dirs with permissions
RUN mkdir -p /app/model_cache && chmod -R 777 /app/model_cache
RUN mkdir -p /app/.streamlit && chmod -R 777 /app/.streamlit

# Pre-download models to cache
RUN python -c "from transformers import pipeline; pipeline('zero-shot-classification', model='facebook/bart-large-mnli')" && \
    python -c "from transformers import pipeline; pipeline('sentiment-analysis', model='distilbert-base-uncased-finetuned-sst-2-english')" && \
    python -c "from transformers import pipeline; pipeline('summarization', model='sshleifer/distilbart-cnn-6-6')" && \
    python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"

EXPOSE 8501
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]