Drrevcade commited on
Commit
8632327
·
verified ·
1 Parent(s): 52da0b9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -26
Dockerfile CHANGED
@@ -1,16 +1,17 @@
1
-
2
  # Use a lightweight Python image
3
  FROM python:3.9-slim
4
 
 
 
 
5
  # Set the working directory
6
  WORKDIR /app
7
 
8
  # Copy the requirements file from the root of the uploaded content
9
  COPY requirements.txt .
10
 
11
- # Install dependencies
12
- RUN pip install --no-cache-dir -r requirements.txt && \
13
- pip install supervisord
14
 
15
  # Copy the application files and the model file from the root of the uploaded content
16
  COPY app.py .
@@ -18,27 +19,27 @@ COPY streamlit_app.py .
18
  COPY best_model.joblib . # Copy the model file
19
 
20
  # Create the supervisord configuration file
21
- RUN mkdir -p /etc/supervisord.d
22
- RUN echo "[supervisord]\n" > /etc.supervisord.conf
23
- RUN echo "nodaemon=true\n" >> /etc.supervisord.conf
24
- RUN echo "[program:flask_app]\n" >> /etc.supervisord.conf
25
- RUN echo "command=gunicorn --bind 0.0.0.0:5000 app:app\n" >> /etc.supervisord.conf # Use gunicorn to serve Flask
26
- RUN echo "directory=/app\n" >> /etc.supervisord.conf
27
- RUN echo "autostart=true\n" >> /etc.supervisord.conf
28
- RUN echo "autorestart=true\n" >> /etc.supervisord.conf
29
- RUN echo "stderr_logfile=/dev/stderr\n" >> /etc.supervisord.conf
30
- RUN echo "stderr_logfile_maxbytes=1MB\n" >> /etc.supervisord.conf
31
- RUN echo "stdout_logfile=/dev/stdout\n" >> /etc.supervisord.conf
32
- RUN echo "stdout_logfile_maxbytes=1MB\n" >> /etc.supervisord.conf
33
- RUN echo "[program:streamlit_app]\n" >> /etc.supervisord.conf
34
- RUN echo "command=streamlit run streamlit_app.py --server.port 7860 --server.address 0.0.0.0\n" >> /etc.supervisord.conf # Streamlit default port 8501, but HF Spaces often uses 7860
35
- RUN echo "directory=/app\n" >> /etc.supervisord.conf
36
- RUN echo "autostart=true\n" >> /etc.supervisord.conf
37
- RUN echo "autorestart=true\n" >> /etc.supervisord.conf
38
- RUN echo "stderr_logfile=/dev/stderr\n" >> /etc.supervisord.conf
39
- RUN echo "stderr_logfile_maxbytes=1MB\n" >> /etc.supervisord.conf
40
- RUN echo "stdout_logfile=/dev/stdout\n" >> /etc.supervisord.conf
41
- RUN echo "stdout_logfile_maxbytes=1MB\n" >> /etc.supervisord.conf
42
 
43
 
44
  # Expose the Streamlit port (Hugging Face Spaces expects 7860 for Streamlit)
@@ -47,4 +48,4 @@ EXPOSE 7860
47
  EXPOSE 5000
48
 
49
  # Command to run supervisord
50
- CMD ["/usr/local/bin/supervisord", "-c", "/etc/supervisord.conf"]
 
 
1
  # Use a lightweight Python image
2
  FROM python:3.9-slim
3
 
4
+ # Install system dependencies including supervisor
5
+ RUN apt-get update && apt-get install -y supervisor && rm -rf /var/lib/apt/lists/*
6
+
7
  # Set the working directory
8
  WORKDIR /app
9
 
10
  # Copy the requirements file from the root of the uploaded content
11
  COPY requirements.txt .
12
 
13
+ # Install Python dependencies
14
+ RUN pip install --no-cache-dir -r requirements.txt
 
15
 
16
  # Copy the application files and the model file from the root of the uploaded content
17
  COPY app.py .
 
19
  COPY best_model.joblib . # Copy the model file
20
 
21
  # Create the supervisord configuration file
22
+ RUN mkdir -p /etc/supervisor/conf.d
23
+ RUN echo "[supervisord]\n" > /etc/supervisor/supervisord.conf # Correct path for supervisord.conf
24
+ RUN echo "nodaemon=true\n" >> /etc/supervisor/supervisord.conf
25
+ RUN echo "[program:flask_app]\n" >> /etc/supervisor/conf.d/flask_app.conf # Correct path for program conf
26
+ RUN echo "command=gunicorn --bind 0.0.0.0:5000 app:app\n" >> /etc/supervisor/conf.d/flask_app.conf # Use gunicorn to serve Flask
27
+ RUN echo "directory=/app\n" >> /etc/supervisor/conf.d/flask_app.conf
28
+ RUN echo "autostart=true\n" >> /etc/supervisor/conf.d/flask_app.conf
29
+ RUN echo "autorestart=true\n" >> /etc/supervisor/conf.d/flask_app.conf
30
+ RUN echo "stderr_logfile=/dev/stderr\n" >> /etc/supervisor/conf.d/flask_app.conf
31
+ RUN echo "stderr_logfile_maxbytes=1MB\n" >> /etc/supervisor/conf.d/flask_app.conf
32
+ RUN echo "stdout_logfile=/dev/stdout\n" >> /etc/supervisor/conf.d/flask_app.conf
33
+ RUN echo "stdout_logfile_maxbytes=1MB\n" >> /etc/supervisor/conf.d/flask_app.conf
34
+ RUN echo "[program:streamlit_app]\n" >> /etc/supervisor/conf.d/streamlit_app.conf # Correct path for program conf
35
+ RUN echo "command=streamlit run streamlit_app.py --server.port 7860 --server.address 0.0.0.0\n" >> /etc/supervisor/conf.d/streamlit_app.conf # Streamlit default port 8501, but HF Spaces often uses 7860
36
+ RUN echo "directory=/app\n" >> /etc/supervisor/conf.d/streamlit_app.conf
37
+ RUN echo "autostart=true\n" >> /etc/supervisor/conf.d/streamlit_app.conf
38
+ RUN echo "autorestart=true\n" >> /etc/supervisor/conf.d/streamlit_app.conf
39
+ RUN echo "stderr_logfile=/dev/stderr\n" >> /etc/supervisor/conf.d/streamlit_app.conf
40
+ RUN echo "stderr_logfile_maxbytes=1MB\n" >> /etc/supervisor/conf.d/streamlit_app.conf
41
+ RUN echo "stdout_logfile=/dev/stdout\n" >> /etc/supervisor/conf.d/streamlit_app.conf
42
+ RUN echo "stdout_logfile_maxbytes=1MB\n" >> /etc/supervisor/conf.d/streamlit_app.conf
43
 
44
 
45
  # Expose the Streamlit port (Hugging Face Spaces expects 7860 for Streamlit)
 
48
  EXPOSE 5000
49
 
50
  # Command to run supervisord
51
+ CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] # Correct path to supervisord executable and conf file