mgbam commited on
Commit
47dd3ab
·
verified ·
1 Parent(s): 648c0bc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -51
Dockerfile CHANGED
@@ -1,58 +1,35 @@
1
- # Use a stable slim Python base image
2
- FROM python:3.10-slim
3
 
4
- # Set environment variables
5
- ENV PYTHONUNBUFFERED=1 \
6
- LANG=C.UTF-8 \
7
- LC_ALL=C.UTF-8 \
8
- PIP_NO_CACHE_DIR=1 \
9
- STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
10
 
11
- # Create working directory and Streamlit config path with correct permissions
12
  WORKDIR /app
13
- RUN useradd -m -u 1000 appuser && \
14
- mkdir -p /home/appuser/.streamlit && \
15
- chown -R appuser /home/appuser && \
16
- apt-get update && apt-get install -y \
17
  build-essential \
18
  curl \
19
  git \
20
- libglib2.0-0 \
21
- libsm6 \
22
- libxrender1 \
23
- libxext6 \
24
- libxml2 \
25
- libxslt1-dev \
26
- libffi-dev \
27
- libbz2-dev \
28
- liblzma-dev \
29
- zlib1g-dev \
30
- libjpeg-dev \
31
- libpq-dev \
32
- gcc \
33
- && apt-get clean && rm -rf /var/lib/apt/lists/*
34
-
35
- # Switch to non-root user for safety
36
- USER appuser
37
-
38
- # Copy requirement files and install dependencies
39
- COPY --chown=appuser:appuser requirements.txt /app/
40
- RUN pip install --upgrade pip && pip install -r requirements.txt
41
-
42
- # Copy rest of the application code
43
- COPY --chown=appuser:appuser . /app
44
-
45
- # Streamlit config
46
- RUN echo "\
47
- [server]\n\
48
- headless = true\n\
49
- port = 8501\n\
50
- enableCORS = false\n\
51
- \n\
52
- [theme]\n\
53
- base = 'light'\n\
54
- " > /home/appuser/.streamlit/config.toml
55
-
56
- # Default command
57
  EXPOSE 8501
58
- CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0"]
 
 
 
 
 
 
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"]