BODDUSWATHISREE commited on
Commit
705bab8
·
verified ·
1 Parent(s): 781cb32

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +45 -4
Dockerfile CHANGED
@@ -1,20 +1,61 @@
1
- FROM python:3.13.5-slim
2
 
3
  WORKDIR /app
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  RUN apt-get update && apt-get install -y \
6
  build-essential \
7
  curl \
 
8
  git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- COPY requirements.txt ./
12
- COPY src/ ./src/
13
 
 
 
14
  RUN pip3 install -r requirements.txt
15
 
 
 
 
 
 
 
 
16
  EXPOSE 8501
17
 
18
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
19
 
20
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
 
3
  WORKDIR /app
4
 
5
+ # Create a non-root user
6
+ RUN useradd -m -u 1000 streamlit
7
+
8
+ # Create directories with proper ownership
9
+ RUN mkdir -p /tmp/.streamlit /tmp/.config/matplotlib /app/uploads && \
10
+ chown -R streamlit:streamlit /tmp/.streamlit /tmp/.config/matplotlib /app && \
11
+ chmod -R 755 /tmp/.streamlit /tmp/.config/matplotlib /app
12
+
13
+ # Set environment variables
14
+ ENV HOME=/tmp
15
+ ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
16
+ ENV MPLCONFIGDIR=/tmp/.config/matplotlib
17
+ ENV STREAMLIT_SERVER_MAX_UPLOAD_SIZE=200
18
+ ENV STREAMLIT_SERVER_ENABLE_CORS=false
19
+ ENV STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false
20
+
21
+ # Install system dependencies
22
  RUN apt-get update && apt-get install -y \
23
  build-essential \
24
  curl \
25
+ software-properties-common \
26
  git \
27
  && rm -rf /var/lib/apt/lists/*
28
 
29
+ # Upgrade pip
30
+ RUN pip3 install --upgrade pip
31
 
32
+ # Copy and install Python dependencies
33
+ COPY requirements.txt ./requirements.txt
34
  RUN pip3 install -r requirements.txt
35
 
36
+ # Copy source code
37
+ COPY src/ ./src/
38
+ RUN chown -R streamlit:streamlit /app
39
+
40
+ # Switch to non-root user
41
+ USER streamlit
42
+
43
  EXPOSE 8501
44
 
45
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
46
 
47
+ # Create Streamlit config file
48
+ RUN echo '[server]\n\
49
+ maxUploadSize = 200\n\
50
+ enableCORS = false\n\
51
+ enableXsrfProtection = false\n\
52
+ \n\
53
+ [browser]\n\
54
+ gatherUsageStats = false\n\
55
+ \n\
56
+ [theme]\n\
57
+ base = "light"' > /tmp/.streamlit/config.toml
58
+
59
+ ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", \
60
+ "--server.port=8501", \
61
+ "--server.address=0.0.0.0"]