Installing docker on the pi:
curl -sSL https://get.docker.com | sh # Install as user, not admin
sudo usermod -aG docker pi
#logout/login pi user
groups # shows docker
docker run hello-world # shows expected result, not error messages
docker version # mine is 20.10.2
python3 -m pip install docker-compose # not sure I have used this yet, might come in handy later
reboot
docker-compose version # mine is 1.28.0
Installing the docker image for the gateway:
docker pull webthingsio/gateway
# configure gateway image, run it & auto-restart, copy files from existing installation
# Make sure to include config/db.sqlite3 and ssl/* so the connection to the webthings.io tunnel works
Running the gateway docker image
docker run \
-d \
-e TZ=Europe/London \
-v /home/pi/<<your chosen path for local gateway files outside of the docker image>>:/home/node/.webthings \
--network="host" \
--log-opt max-size=1m \
--log-opt max-file=10 \
--name webthings-gateway \
webthingsio/gateway:latest
To start fresh again if things go badly (and change some configuration):
docker stop webthings-gateway
docker container rm webthings-gateway
As to the SHA image, every addon has a SHA256SUMS file so the gateway can check they have not been tampered with. If you edit addon files in their gateway directory directly, you need to update this file. See further for details.
Example of the files in a typical addon:
> ll thing-url-adapter/
total 92
drwxr-xr-x 3 pi pi 4096 2021-01-18 19:07:18 .
drwxr-xr-x 9 pi pi 4096 2021-02-17 23:16:32 ..
-rw-r--r-- 1 pi pi 317 2020-12-23 01:29:26 index.js
-rw-r--r-- 1 pi pi 16725 2020-12-23 01:29:26 LICENSE
-rw-r--r-- 1 pi pi 1867 2020-12-23 01:29:26 manifest.json
drwxr-xr-x 6 pi pi 4096 2020-12-23 01:29:26 node_modules
-rw-r--r-- 1 pi pi 787 2020-12-23 01:29:26 package.json
-rw-r--r-- 1 pi pi 1730 2020-12-23 01:29:26 README.md
-rw-r--r-- 1 pi pi 18232 2020-12-23 01:29:26 SHA256SUMS
-rw-r--r-- 1 pi pi 24019 2020-12-23 01:29:26 thing-url-adapter.js
For my own addons, I created a file called sha.sh with contents as follows:
#!/bin/bash
# first make sure the owner is correct for every file in this directory and subdirectories
chown -R pi:pi .
# then find every relevant file and add the shasum to the SHA file
find . -path './pkg/__pycache__' -prune -o -type f -not -name '*.swp' -exec sha256sum {} + > SHA256SUMS
cat SHA256SUMS
One last tip: whenever an instruction tells you to pip install XYZ
, or pip3 install XYZ
, I have found it more reliable to replace this instruction with python3 -m pip install XYZ
.