mgbam commited on
Commit
88caf8f
·
verified ·
1 Parent(s): 47dd3ab

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -18
Dockerfile CHANGED
@@ -1,35 +1,31 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.9-slim
3
 
4
- # Set environment variables to prevent Python from writing .pyc files and to buffer outputs
5
- ENV PYTHONDONTWRITEBYTECODE=1
6
- ENV PYTHONUNBUFFERED=1
7
 
8
- # Set the working directory in the container
9
  WORKDIR /app
10
 
11
  # Install system dependencies
12
- RUN apt-get update && apt-get install -y \
13
  build-essential \
14
  curl \
15
- git \
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
- # Copy the requirements file into the container
19
  COPY requirements.txt .
 
20
 
21
- # Install Python dependencies
22
- RUN pip install --upgrade pip && \
23
- pip install --no-cache-dir -r requirements.txt
24
-
25
- # Copy the rest of the application code into the container
26
  COPY . .
27
 
28
- # Expose the port that Streamlit uses
29
  EXPOSE 8501
30
 
31
- # Set the entry point to run the Streamlit application
32
- ENTRYPOINT ["streamlit", "run"]
33
 
34
- # Specify the default command to run the app
35
- CMD ["app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
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"]