Greg-House commited on
Commit
b49ecd7
·
verified ·
1 Parent(s): 3532d53

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -3
Dockerfile CHANGED
@@ -1,12 +1,33 @@
 
1
  FROM python:3.9-slim
2
 
 
3
  WORKDIR /code
4
 
 
5
  COPY ./requirements.txt /code/requirements.txt
 
 
 
6
  COPY ./ /code/
7
 
8
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- EXPOSE 7860
 
11
 
12
- CMD ["python", "app.py"]
 
 
1
+ # Use Python 3.9 base image
2
  FROM python:3.9-slim
3
 
4
+ # Set the working directory
5
  WORKDIR /code
6
 
7
+ # Copy and install Python dependencies
8
  COPY ./requirements.txt /code/requirements.txt
9
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
10
+
11
+ # Copy the rest of the application code
12
  COPY ./ /code/
13
 
14
+ # Install additional dependencies for Prometheus and Grafana
15
+ RUN apt-get update && \
16
+ apt-get install -y curl gnupg && \
17
+ curl -s https://packages.grafana.com/gpg.key | apt-key add - && \
18
+ echo "deb https://packages.grafana.com/oss/deb stable main" | tee /etc/apt/sources.list.d/grafana.list && \
19
+ apt-get update && \
20
+ apt-get install -y grafana && \
21
+ apt-get clean
22
+
23
+ # Install Prometheus Node Exporter (for server metrics)
24
+ RUN curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz && \
25
+ tar xzf node_exporter-1.5.0.linux-amd64.tar.gz && \
26
+ mv node_exporter-1.5.0.linux-amd64/node_exporter /usr/local/bin/ && \
27
+ rm -rf node_exporter-1.5.0.linux-amd64*
28
 
29
+ # Expose the application port and Grafana port
30
+ EXPOSE 7860 3000
31
 
32
+ # Start Prometheus Node Exporter, Grafana, and your app
33
+ CMD ["sh", "-c", "/usr/local/bin/node_exporter & /usr/sbin/grafana-server --homepath=/usr/share/grafana & python app.py"]