mgbam commited on
Commit
4cc7b5d
·
verified ·
1 Parent(s): 88caf8f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -22
Dockerfile CHANGED
@@ -1,31 +1,40 @@
1
- # Use an official lightweight Python image
2
- FROM python:3.9-slim
3
 
4
- # Set environment variables to prevent Python from writing .pyc files and buffering stdout/stderr
5
- ENV PYTHONUNBUFFERED=1 \
6
- PYTHONDONTWRITEBYTECODE=1
7
-
8
- # Set the working directory inside the container
9
  WORKDIR /app
10
 
11
- # Install system dependencies
12
- RUN apt-get update && apt-get install -y --no-install-recommends \
13
- build-essential \
14
- curl \
15
- && rm -rf /var/lib/apt/lists/*
16
-
17
- # Copy the requirements file and install Python dependencies
18
  COPY requirements.txt .
19
- RUN pip install --no-cache-dir -r requirements.txt
20
 
21
- # Copy the rest of the application code
22
  COPY . .
23
 
24
- # Expose the port that Streamlit listens on
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  EXPOSE 8501
26
 
27
- # Healthcheck to ensure the app is running
28
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
29
-
30
- # Run the Streamlit app
31
- CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ # Base image
2
+ FROM python:3.10-slim
3
 
4
+ # Set working directory
 
 
 
 
5
  WORKDIR /app
6
 
7
+ # Install dependencies
 
 
 
 
 
 
8
  COPY requirements.txt .
9
+ RUN pip install --upgrade pip && pip install -r requirements.txt
10
 
11
+ # Copy app source code
12
  COPY . .
13
 
14
+ # Make sure streamlit is executable
15
+ RUN chmod +x /usr/local/bin/streamlit
16
+
17
+ # Avoid writing to system root, Streamlit tries to save telemetry
18
+ ENV STREAMLIT_HOME=/home/appuser
19
+ ENV HOME=/home/appuser
20
+ RUN mkdir -p $HOME/.streamlit
21
+
22
+ # Write basic config to avoid permission error
23
+ RUN echo "\
24
+ [general]\n\
25
+ email = \"\"\n\
26
+ \n\
27
+ [server]\n\
28
+ headless = true\n\
29
+ enableCORS = false\n\
30
+ port = 8501\n\
31
+ \n\
32
+ [browser]\n\
33
+ gatherUsageStats = false\n\
34
+ " > $HOME/.streamlit/config.toml
35
+
36
+ # Set default port
37
  EXPOSE 8501
38
 
39
+ # Start Streamlit
40
+ CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=8501"]