userIdc2024 commited on
Commit
17740fa
·
verified ·
1 Parent(s): 546d498

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -7
Dockerfile CHANGED
@@ -1,20 +1,38 @@
1
  FROM python:3.13.5-slim
2
 
 
 
 
 
 
 
 
 
 
 
3
  WORKDIR /app
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
  curl \
8
- git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
 
 
 
 
11
  COPY requirements.txt ./
12
- COPY . .
13
 
14
- RUN pip3 install -r requirements.txt
 
15
 
16
  EXPOSE 8501
17
 
18
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
 
 
19
 
20
- ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
 
 
1
  FROM python:3.13.5-slim
2
 
3
+ # Avoid interactive tzdata prompts and keep logs unbuffered
4
+ ENV DEBIAN_FRONTEND=noninteractive \
5
+ PYTHONUNBUFFERED=1 \
6
+ PIP_NO_CACHE_DIR=1 \
7
+ # Make Streamlit write to a writable place (fixes '/.streamlit' permission error)
8
+ HOME=/app \
9
+ XDG_CONFIG_HOME=/app/.config \
10
+ STREAMLIT_CONFIG_DIR=/app/.streamlit \
11
+ STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
12
+
13
  WORKDIR /app
14
 
15
+ # Minimal OS deps you actually need (curl for healthcheck, build-essential for any wheels that need compile)
16
+ RUN apt-get update && apt-get install -y --no-install-recommends \
17
  curl \
18
+ build-essential \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
+ # Pre-create streamlit config dir (in case Streamlit tries to write during boot)
22
+ RUN mkdir -p /app/.streamlit
23
+
24
+ # Install Python deps first to leverage Docker layer cache
25
  COPY requirements.txt ./
26
+ RUN pip install -r requirements.txt
27
 
28
+ # Now add the rest of the app
29
+ COPY . .
30
 
31
  EXPOSE 8501
32
 
33
+ # Healthcheck (streamlit exposes this)
34
+ HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
35
+ CMD curl --fail http://localhost:8501/_stcore/health || exit 1
36
 
37
+ # Run Streamlit
38
+ ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]