rdz-falcon commited on
Commit
0f292b9
·
verified ·
1 Parent(s): 0550aed

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -10
Dockerfile CHANGED
@@ -1,26 +1,30 @@
1
  FROM python:3.9-slim
2
 
3
  WORKDIR /app
4
- # Ensure Streamlit can write its installation_id, metrics, etc.
5
- RUN mkdir -p /root/.streamlit \
6
- && chown -R 1000:1000 /root/.streamlit \
7
- && chmod -R a+rwX /root/.streamlit
8
 
 
9
  RUN mkdir -p /app/.cache_app && \
10
  chown -R 1000:1000 /app/.cache_app && \
11
  chmod -R u+rwx,g+rwx /app/.cache_app
12
 
 
 
13
  ENV STREAMLIT_HOME=/app/.streamlit_config
14
- # Create and set permissions for Streamlit's configuration directory
15
  RUN mkdir -p ${STREAMLIT_HOME} && \
16
  chown -R 1000:1000 ${STREAMLIT_HOME} && \
17
  chmod -R u+rwx,g+rwx ${STREAMLIT_HOME}
18
- # --- ^ ^ ^ END OF STREAMLIT PERMISSION FIX ^ ^ ^ ---
19
 
20
- # Set TOKENIZERS_PARALLELISM to false to avoid warnings (optional but good practice)
 
 
 
 
 
 
21
  ENV TOKENIZERS_PARALLELISM=false
22
 
23
- RUN apt-get update && apt-get install -y \
 
24
  build-essential \
25
  cmake \
26
  curl \
@@ -28,13 +32,19 @@ RUN apt-get update && apt-get install -y \
28
  git \
29
  && rm -rf /var/lib/apt/lists/*
30
 
 
 
31
  COPY requirements.txt ./
32
- COPY src/ ./src/
33
 
34
- RUN pip3 install -r requirements.txt
 
35
 
 
36
  EXPOSE 8501
37
 
 
38
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
39
 
 
40
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.fileWatcherType", "none"]
 
1
  FROM python:3.9-slim
2
 
3
  WORKDIR /app
 
 
 
 
4
 
5
+ # Create and permission the general application cache directory
6
  RUN mkdir -p /app/.cache_app && \
7
  chown -R 1000:1000 /app/.cache_app && \
8
  chmod -R u+rwx,g+rwx /app/.cache_app
9
 
10
+ # --- V V V STREAMLIT PERMISSION FIXES V V V ---
11
+ # 1. For user-level Streamlit configurations (good practice)
12
  ENV STREAMLIT_HOME=/app/.streamlit_config
 
13
  RUN mkdir -p ${STREAMLIT_HOME} && \
14
  chown -R 1000:1000 ${STREAMLIT_HOME} && \
15
  chmod -R u+rwx,g+rwx ${STREAMLIT_HOME}
 
16
 
17
+ # 2. For the problematic root-level /.streamlit directory (direct fix for the error)
18
+ RUN mkdir -p /.streamlit && \
19
+ chmod -R 777 /.streamlit
20
+ # This creates /.streamlit during build (owned by root) and makes it world-writable.
21
+ # --- ^ ^ ^ END OF STREAMLIT PERMISSION FIXES ^ ^ ^ ---
22
+
23
+ # Set TOKENIZERS_PARALLELISM to false to avoid warnings
24
  ENV TOKENIZERS_PARALLELISM=false
25
 
26
+ # Install system dependencies
27
+ RUN apt-get update && apt-get install -y --no-install-recommends \
28
  build-essential \
29
  cmake \
30
  curl \
 
32
  git \
33
  && rm -rf /var/lib/apt/lists/*
34
 
35
+ # Copy requirements file and install Python dependencies
36
+ # (Installing requirements before copying all app code improves Docker layer caching)
37
  COPY requirements.txt ./
38
+ RUN pip3 install --no-cache-dir -r requirements.txt
39
 
40
+ # Copy your application source code
41
+ COPY src/ ./src/
42
 
43
+ # Expose the port Streamlit will run on
44
  EXPOSE 8501
45
 
46
+ # Healthcheck
47
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
48
 
49
+ # Entrypoint to run your Streamlit application
50
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.fileWatcherType", "none"]