simran0608 commited on
Commit
776f231
·
verified ·
1 Parent(s): e7536b9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -7
Dockerfile CHANGED
@@ -1,8 +1,11 @@
1
  FROM python:3.9-slim
2
 
 
 
 
3
  WORKDIR /app
4
 
5
- # Install system dependencies including libgl1 (fixes ImportError)
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
  curl \
@@ -11,16 +14,23 @@ RUN apt-get update && apt-get install -y \
11
  libgl1 \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # Set up writable config directories to fix PermissionError
15
- RUN mkdir -p /app/.streamlit /app/.config
 
 
 
16
  ENV HOME=/app
17
  ENV XDG_CONFIG_HOME=/app/.config
18
 
19
- COPY requirements.txt ./
20
- COPY src/ ./src/
 
 
 
 
21
 
22
- # Install Python dependencies
23
- RUN pip3 install --no-cache-dir -r requirements.txt
24
 
25
  EXPOSE 8501
26
 
 
1
  FROM python:3.9-slim
2
 
3
+ # Create non-root user
4
+ RUN useradd -m streamlituser
5
+
6
  WORKDIR /app
7
 
8
+ # Install system dependencies
9
  RUN apt-get update && apt-get install -y \
10
  build-essential \
11
  curl \
 
14
  libgl1 \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Set up config dirs and set permissions
18
+ RUN mkdir -p /app/.streamlit /app/.config /app/src && \
19
+ chown -R streamlituser:streamlituser /app
20
+
21
+ # Set environment variables
22
  ENV HOME=/app
23
  ENV XDG_CONFIG_HOME=/app/.config
24
 
25
+ # Switch to non-root user
26
+ USER streamlituser
27
+
28
+ # Copy files after switching to the user to preserve ownership
29
+ COPY --chown=streamlituser:streamlituser requirements.txt ./
30
+ COPY --chown=streamlituser:streamlituser src/ ./src/
31
 
32
+ # Install dependencies
33
+ RUN pip install --no-cache-dir -r requirements.txt
34
 
35
  EXPOSE 8501
36