diff --git a/Dockerfile b/Dockerfile index da918c3..f388fcf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM fedora:36-armhfp +FROM fedora:36 RUN dnf -y update RUN dnf -y install libgpiod-utils python3-libgpiod swig python2 python-setuptools python-devel python3-devel python-setuptools python3-setuptools unzip curl wget make gcc which git @@ -15,7 +15,5 @@ RUN if [[ -d "/usr/lib" ]]; then cp /usr/local/lib/lib*gpio.so.1 /usr/lib/; RUN mkdir /src -COPY fan.py /src - RUN mkdir -p /var/lib/node_exporter; \ touch /var/lib/node_exporter/fan-metrics.prom diff --git a/README.md b/README.md index bbf2b34..e251f27 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,18 @@ view node-exporter metrics: # sudo tail -f /var/lib/node_exporter/fan-metrics.prom ``` +## build image and run container with docker compose + +An example to simply run the fan.py script can be found in `docker-compose.yaml`. To run it, type: +``` +# docker compose up -d +``` + +Check the script output with: +``` +# docker compose logs -f --tail 10` +``` + ## Fan metrics using node-exporter, prometheus and grafana When the --node-exporter parameter is used, the fan.py script writes the following metrics every interval in /var/lib/node_exporter/fan-metrics.prom: diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..cc1913b --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,16 @@ +version: '3.8' + +services: + gpioexperiment: + image: gpio + build: . + container_name: gpio_experiment + restart: unless-stopped + volumes: + - type: bind + source: ./fan.py + target: /src/fan.py + command: /usr/bin/python3 -u /src/fan.py --verbose + devices: + - /dev/gpiochip0 +