UDface11jkj commited on
Commit
66102ec
·
verified ·
1 Parent(s): d45f61f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -26
Dockerfile CHANGED
@@ -1,42 +1,36 @@
 
1
  FROM python:3.10-slim
2
 
3
- # Install system dependencies
4
- RUN apt-get update && apt-get install -y \
5
- build-essential \
6
- curl \
7
- software-properties-common \
8
- git \
9
- libjpeg-dev \
10
- zlib1g-dev \
11
- && rm -rf /var/lib/apt/lists/*
12
-
13
- # Create a non-root user
14
- RUN useradd -m streamlit_user
15
 
16
  # Set working directory
17
  WORKDIR /home/streamlit_user/app
18
 
19
- # Set permissions so non-root user can write to this directory
20
- RUN chown -R streamlit_user:streamlit_user /home/streamlit_user/app
 
 
 
 
 
21
 
22
- # Switch to non-root user
23
- USER streamlit_user
24
 
25
- # Make sure pip-installed binaries are available
26
- ENV PATH="/home/streamlit_user/.local/bin:$PATH"
 
27
 
28
- # Copy files to the new working directory
29
- COPY requirements.txt ./requirements.txt
30
  COPY src/ ./src/
31
 
32
- # Install dependencies as the non-root user
33
- RUN pip install --user --no-cache-dir -r requirements.txt
34
-
35
- # Expose Streamlit's default port
36
  EXPOSE 8501
37
 
38
- # Health check for container
39
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
40
 
41
  # Run the Streamlit app
42
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ # Use the official lightweight Python image
2
  FROM python:3.10-slim
3
 
4
+ # Set environment variables to avoid prompts during installs
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
 
 
 
 
 
 
 
 
 
7
 
8
  # Set working directory
9
  WORKDIR /home/streamlit_user/app
10
 
11
+ # Install system dependencies
12
+ RUN apt-get update && apt-get install -y --no-install-recommends \
13
+ build-essential \
14
+ git \
15
+ curl \
16
+ libgl1-mesa-glx \
17
+ && rm -rf /var/lib/apt/lists/*
18
 
19
+ # Copy requirements first to leverage Docker cache
20
+ COPY requirements.txt ./requirements.txt
21
 
22
+ # Install Python dependencies
23
+ RUN pip install --upgrade pip && \
24
+ pip install --no-cache-dir -r requirements.txt
25
 
26
+ # Copy the rest of your app files
 
27
  COPY src/ ./src/
28
 
29
+ # Expose Streamlit default port
 
 
 
30
  EXPOSE 8501
31
 
32
+ # Streamlit specific environment variable to disable browser opening
33
+ ENV STREAMLIT_SERVER_HEADLESS=true
34
 
35
  # Run the Streamlit app
36
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]