File size: 1,223 Bytes
1fa9052
 
 
 
8a4bd37
c51a29a
 
 
dd0f8be
 
c51a29a
1fa9052
 
 
 
 
 
 
8a4bd37
dd0f8be
 
1fa9052
8a4bd37
 
 
 
 
1fa9052
 
c51a29a
 
 
 
1fa9052
 
 
 
a5333c6
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
FROM python:3.9-slim

WORKDIR /app

# Set environment variables
ENV HOME=/tmp
ENV STREAMLIT_SERVER_HEADLESS=true
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
ENV HUGGINGFACE_HUB_CACHE=/tmp/huggingface_cache
ENV TRANSFORMERS_CACHE=/tmp/huggingface_cache

RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    software-properties-common \
    git \
    && rm -rf /var/lib/apt/lists/*

# Create cache directory
RUN mkdir -p /tmp/huggingface_cache && chmod 777 /tmp/huggingface_cache

COPY requirements.txt ./
RUN pip3 install -r requirements.txt

# Pre-download the model during build time
RUN python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('BAAI/bge-small-en'); print('Model downloaded successfully')"

COPY src/ ./src/

# Create .streamlit directory and config file
RUN mkdir -p /tmp/.streamlit
RUN echo '[server]\nheadless = true\nport = 8501\nenableCORS = false\nenableXsrfProtection = false\n\n[browser]\ngatherUsageStats = false' > /tmp/.streamlit/config.toml

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]