akashraut commited on
Commit
2a8700a
·
verified ·
1 Parent(s): 59f13db

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -5
Dockerfile CHANGED
@@ -1,4 +1,5 @@
1
  FROM python:3.10-slim
 
2
  WORKDIR /app
3
 
4
  # Copy and install your Python deps
@@ -11,18 +12,25 @@ COPY src/ /app/src/
11
  # Expose the port Streamlit will run on
12
  EXPOSE 8501
13
 
14
- # 1️⃣ Create writable cache/config under /tmp
 
 
 
15
  RUN mkdir -p /tmp/.cache/transformers \
16
  /tmp/.cache/huggingface \
17
  /tmp/.cache/xdg \
18
- /tmp/.streamlit
 
 
 
 
19
 
20
- # 2️⃣ Point all caches and Streamlit config into /tmp
21
  ENV TRANSFORMERS_CACHE=/tmp/.cache/transformers \
22
  HF_HOME=/tmp/.cache/huggingface \
23
  XDG_CACHE_HOME=/tmp/.cache/xdg \
24
  STREAMLIT_CONFIG_DIR=/tmp/.streamlit
25
 
26
- # 3️⃣ Launch your app
27
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", \
28
- "--server.port=8501", "--server.address=0.0.0.0"]
 
1
  FROM python:3.10-slim
2
+
3
  WORKDIR /app
4
 
5
  # Copy and install your Python deps
 
12
  # Expose the port Streamlit will run on
13
  EXPOSE 8501
14
 
15
+ # 1️⃣ Create a non-root user
16
+ RUN useradd -m -u 1000 user
17
+
18
+ # 2️⃣ Create writable cache directories and change ownership
19
  RUN mkdir -p /tmp/.cache/transformers \
20
  /tmp/.cache/huggingface \
21
  /tmp/.cache/xdg \
22
+ /tmp/.streamlit && \
23
+ chown -R user:user /tmp/.cache
24
+
25
+ # 3️⃣ Switch to the non-root user
26
+ USER user
27
 
28
+ # 4️⃣ Point all caches and Streamlit config into /tmp
29
  ENV TRANSFORMERS_CACHE=/tmp/.cache/transformers \
30
  HF_HOME=/tmp/.cache/huggingface \
31
  XDG_CACHE_HOME=/tmp/.cache/xdg \
32
  STREAMLIT_CONFIG_DIR=/tmp/.streamlit
33
 
34
+ # 5️⃣ Launch your app
35
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", \
36
+ "--server.port=8501", "--server.address=0.0.0.0"]