ysif9 commited on
Commit
65da834
·
verified ·
1 Parent(s): 42e57f6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -5
Dockerfile CHANGED
@@ -1,5 +1,6 @@
1
  FROM python:3.13.5-slim
2
 
 
3
  WORKDIR /app
4
 
5
  RUN apt-get update && apt-get install -y \
@@ -8,22 +9,40 @@ RUN apt-get update && apt-get install -y \
8
  git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
 
11
  COPY requirements.txt ./
12
  RUN pip3 install --no-cache-dir -r requirements.txt
13
 
14
- # Ensure writable Streamlit paths and disable telemetry
15
- ENV STREAMLIT_HOME=/app/.streamlit \
 
16
  STREAMLIT_CACHE_DIR=/app/.streamlit/cache \
17
  STREAMLIT_USER_PATH=/app/.streamlit \
18
  STREAMLIT_DISABLE_TELEMETRY=1 \
19
- PYTHONUNBUFFERED=1
 
20
 
21
- RUN mkdir -p /app/.streamlit/cache
 
 
22
 
 
 
 
 
 
 
 
23
  COPY src/ ./src/
24
 
25
- EXPOSE 8501
 
 
 
26
 
 
 
27
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
28
 
 
29
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
  FROM python:3.13.5-slim
2
 
3
+ # System setup
4
  WORKDIR /app
5
 
6
  RUN apt-get update && apt-get install -y \
 
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Install Python dependencies
13
  COPY requirements.txt ./
14
  RUN pip3 install --no-cache-dir -r requirements.txt
15
 
16
+ # Environment: ensure Streamlit writes under /app and disable telemetry
17
+ ENV HOME=/app \
18
+ STREAMLIT_HOME=/app/.streamlit \
19
  STREAMLIT_CACHE_DIR=/app/.streamlit/cache \
20
  STREAMLIT_USER_PATH=/app/.streamlit \
21
  STREAMLIT_DISABLE_TELEMETRY=1 \
22
+ PYTHONUNBUFFERED=1 \
23
+ PIP_NO_CACHE_DIR=1
24
 
25
+ # Prepare writable directories
26
+ RUN mkdir -p /app/.streamlit/cache \
27
+ && chmod -R 777 /app/.streamlit
28
 
29
+ # Optionally create XDG dirs to be safe with other libs/tools
30
+ ENV XDG_CONFIG_HOME=/app/.config \
31
+ XDG_CACHE_HOME=/app/.cache
32
+ RUN mkdir -p /app/.config /app/.cache \
33
+ && chmod -R 777 /app/.config /app/.cache
34
+
35
+ # Copy application code
36
  COPY src/ ./src/
37
 
38
+ # Create a non-root user and give ownership of /app
39
+ RUN useradd -m -u 1000 appuser \
40
+ && chown -R appuser:appuser /app
41
+ USER appuser
42
 
43
+ # Networking and healthcheck
44
+ EXPOSE 8501
45
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
46
 
47
+ # Run Streamlit app
48
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]