├── .gitignore ├── Dockerfile ├── README.md ├── docker-compose.yml └── entrypoint.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | 3 | STOPSIGNAL 9 4 | 5 | RUN apk --update --no-cache add --virtual build-dependencies build-base && \ 6 | cd /tmp && \ 7 | wget https://github.com/joan2937/pigpio/archive/master.zip && \ 8 | unzip -qq master.zip && \ 9 | cd pigpio-master && \ 10 | make && \ 11 | sed -i 's/ldconfig/ldconfig \/usr\/local/g' Makefile && \ 12 | make install && \ 13 | apk del build-dependencies && \ 14 | rm -rf /tmp/* && \ 15 | apk --no-cache add tini 16 | 17 | COPY entrypoint.sh /entrypoint.sh 18 | 19 | ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"] 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # node-red-gpiod 2 | 3 | [![DockerHub Pull](https://img.shields.io/docker/pulls/corbosman/pigpiod.svg)](https://hub.docker.com/r/corbosman/pigpiod/) 4 | 5 | __note: this is still in development, feedback is appreciated__ 6 | 7 | This is a docker image that lets you run [pigpiod](http://abyz.me.uk/rpi/pigpio/pigpiod.html) in a dedicated container on a Raspberry PI. 8 | Pigpiod is a daemon for controlling gpio pins over the network. You can then control these pins remotely through software like Node-Red, which provides [dedicated nodes](https://www.npmjs.com/package/node-red-node-pi-gpiod). 9 | 10 | ## Quick Start 11 | 12 | To run this container stand-alone you can start it like this: 13 | 14 | ``` 15 | docker run -d -p 8888:8888 --privileged --name gpiod corbosman/pigpiod 16 | ``` 17 | 18 | The daemon is now listening on port 8888 on localhost. 19 | Because the daemon needs to access device pins on the Raspberry PI, it is necessary to run the container in privileged mode. 20 | 21 | To stop it: 22 | 23 | ``` 24 | docker stop gpiod 25 | ``` 26 | 27 | This image allows you to pass additional arguments to the daemon. For a list of all available arguments check the [pigpiod](http://abyz.me.uk/rpi/pigpio/pigpiod.html) website. 28 | Simply add arguments after the image name like so: 29 | 30 | 31 | ``` 32 | docker run -d -p 8888:8888 --privileged --name gpiod corbosman/pigpiod -n 127.0.0.1 -s 2 33 | ``` 34 | 35 | __note: the options "-g -a 1" are always passed to the daemon"__ 36 | 37 | ## Running through docker-compose 38 | 39 | A better way to run this daemon is by creating a container stack with for example node-red and possibly other containers like mosquitto. A sample docker-compose.yml can be found in the github repository at https://github.com/corbosman/node-red-gpiod. 40 | This allows you to run the pigpiod daemon in a protected network that is only accessible by Node-Red. 41 | 42 | ``` 43 | version: "3" 44 | 45 | services: 46 | node-red: 47 | image: nodered/node-red 48 | volumes: 49 | - /home/pi/.node-red:/data 50 | ports: 51 | - 1880:1880 52 | 53 | gpiod: 54 | image: corbosman/pigpiod 55 | privileged: true 56 | restart: unless-stopped 57 | ``` 58 | 59 | This compose file will start up Node-Red and gpiod services, with only the Node-Red service exposed to the outside on port 1880. 60 | To connect to the daemon from the gpiod node in Node-Red, simply use the service name "gpiod" as the hostname, and port 8888. 61 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | node-red: 5 | image: nodered/node-red 6 | volumes: 7 | - /home/pi/.node-red:/data 8 | ports: 9 | - 1880:1880 10 | 11 | gpiod: 12 | image: corbosman/node-red-gpiod:dev 13 | privileged: true 14 | restart: unless-stopped 15 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | echo "Starting PigPiod..." 6 | 7 | # gpiod sometimes leaves pid files around, just clean them 8 | rm -f /var/run/pigpio.pid 9 | 10 | exec /usr/local/bin/pigpiod -g -a 1 $@ 11 | --------------------------------------------------------------------------------