File size: 1,524 Bytes
6448b52
5a99db7
 
 
ca4b9c6
 
6e8350a
ca4b9c6
 
 
 
 
 
f4871ef
 
 
ca4b9c6
 
 
6e8350a
f4871ef
5a99db7
 
 
 
 
 
 
f4871ef
0323559
 
f4871ef
e2b05ce
5a99db7
 
f4871ef
 
ca4b9c6
 
 
 
f4871ef
5a99db7
 
 
 
ca4b9c6
 
 
 
 
 
 
 
 
 
 
 
f4871ef
 
ca4b9c6
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
58
59
60
61
FROM python:3.11-slim

WORKDIR /app

# Create a non-root user
RUN useradd -m -u 1000 streamlit

# Create directories with proper ownership
RUN mkdir -p /tmp/.streamlit /tmp/.config/matplotlib /app/uploads && \
    chown -R streamlit:streamlit /tmp/.streamlit /tmp/.config/matplotlib /app && \
    chmod -R 755 /tmp/.streamlit /tmp/.config/matplotlib /app

# Set environment variables
ENV HOME=/tmp
ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
ENV MPLCONFIGDIR=/tmp/.config/matplotlib
ENV STREAMLIT_SERVER_MAX_UPLOAD_SIZE=200
ENV STREAMLIT_SERVER_ENABLE_CORS=false
ENV STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false

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

# Upgrade pip
RUN pip3 install --upgrade pip

# Copy and install Python dependencies
COPY requirements.txt ./requirements.txt
RUN pip3 install -r requirements.txt

# Copy source code
COPY src/ ./src/
RUN chown -R streamlit:streamlit /app

# Switch to non-root user
USER streamlit

EXPOSE 8501

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

# Create Streamlit config file
RUN echo '[server]\n\
maxUploadSize = 200\n\
enableCORS = false\n\
enableXsrfProtection = false\n\
\n\
[browser]\n\
gatherUsageStats = false\n\
\n\
[theme]\n\
base = "light"' > /tmp/.streamlit/config.toml

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