AreejMehboob commited on
Commit
7770a54
·
verified ·
1 Parent(s): 7a0f24e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -7
Dockerfile CHANGED
@@ -2,20 +2,40 @@ FROM python:3.9-slim
2
 
3
  WORKDIR /app
4
 
 
5
  RUN apt-get update && apt-get install -y \
6
  build-essential \
7
  curl \
8
- software-properties-common \
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- COPY requirements.txt ./
13
- COPY src/ ./src/
 
14
 
15
- RUN pip3 install -r requirements.txt
 
16
 
17
- EXPOSE 8501
 
 
 
 
 
 
 
18
 
19
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
 
 
 
 
 
 
 
 
 
 
20
 
21
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
  curl \
 
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Create a non-root user and give permissions to /app
13
+ RUN useradd -m -u 1000 streamlituser && \
14
+ chown -R streamlituser:streamlituser /app
15
 
16
+ # Switch to non-root user
17
+ USER streamlituser
18
 
19
+ # Copy requirements first to leverage Docker cache
20
+ COPY --chown=streamlituser:streamlituser requirements.txt ./
21
+
22
+ # Install Python dependencies
23
+ RUN pip install --no-cache-dir -r requirements.txt
24
+
25
+ # Copy application code
26
+ COPY --chown=streamlituser:streamlituser src/ ./src/
27
 
28
+ # Environment variables
29
+ ENV STREAMLIT_GATHER_USAGE_STATS=False \
30
+ STREAMLIT_SERVER_PORT=8501 \
31
+ STREAMLIT_SERVER_ADDRESS=0.0.0.0
32
+
33
+ # Healthcheck
34
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
35
+ CMD curl --fail http://localhost:8501/_stcore/health
36
+
37
+ # Expose port
38
+ EXPOSE 8501
39
 
40
+ # Entrypoint
41
+ ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py"]