abdo-Mansour commited on
Commit
27e770e
Β·
verified Β·
1 Parent(s): 5148618

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -15
Dockerfile CHANGED
@@ -1,28 +1,35 @@
1
  FROM python:3.11.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
- # ─── STREAMLIT PERMISSION FIX ─────────────────────────────
18
- ENV HOME=/tmp \
19
- STREAMLIT_DATA_DIR=/tmp/.streamlit \
20
- XDG_CONFIG_HOME=/tmp/.streamlit
21
- RUN mkdir -p /tmp/.streamlit
22
- # ───────────────────────────────────────────────────────────
 
 
 
23
 
24
  EXPOSE 8501
25
-
26
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
27
 
28
  ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
  FROM python:3.11.9-slim
2
 
3
+ # 1) System deps
 
4
  RUN apt-get update && apt-get install -y \
5
+ build-essential \
6
+ curl \
7
+ software-properties-common \
8
+ git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # 2) Create app user with home dir
12
+ RUN useradd -m -u 10001 -s /usr/sbin/nologin appuser
13
+
14
+ WORKDIR /app
15
+ # Make sure /app is owned by our user
16
+ RUN chown appuser:appuser /app
17
 
18
+ # 3) Copy & install Python deps as root
19
+ COPY requirements.txt .
20
  RUN pip3 install -r requirements.txt
21
 
22
+ # 4) Copy your source & switch to non‑root
23
+ COPY src/ ./src/
24
+ USER appuser
25
+
26
+ # 5) Ensure Streamlit config dir exists in the new home
27
+ ENV HOME=/home/appuser \
28
+ STREAMLIT_DATA_DIR=/home/appuser/.streamlit \
29
+ XDG_CONFIG_HOME=/home/appuser/.streamlit
30
+ RUN mkdir -p /home/appuser/.streamlit
31
 
32
  EXPOSE 8501
 
33
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
34
 
35
  ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]