Skip to content

Commit 90e5583

Browse files
committed
Upgrade Docker image to Node.js 20 and Debian Bookworm - closes #3185
1 parent 5e454bc commit 90e5583

File tree

7 files changed

+40
-28
lines changed

7 files changed

+40
-28
lines changed

Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
FROM node:12-buster-slim
1+
FROM node:20-bookworm-slim
22

33
EXPOSE 8080 4443
44

55
ARG DEBIAN_FRONTEND=noninteractive
66
RUN set -x && \
7-
echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list && \
87
apt update && \
98
apt dist-upgrade -y && \
109
apt install -y \
@@ -15,19 +14,21 @@ RUN set -x && \
1514
git \
1615
iputils-ping \
1716
libcap2-bin \
17+
libdbus-1-dev \
1818
libffi-dev \
1919
libnss-mdns \
2020
libpng-dev \
2121
libtool \
2222
lsb-release \
2323
mosquitto \
2424
net-tools \
25+
pipx \
2526
pkg-config \
26-
python \
27-
python-six \
2827
python3 \
2928
python3-pip \
3029
python3-setuptools \
30+
python3-six \
31+
python-is-python3 \
3132
sudo \
3233
zlib1g-dev && \
3334
apt clean && \
@@ -37,7 +38,9 @@ RUN set -x && \
3738
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
3839

3940
COPY --chown=node:node . /home/node/webthings/gateway/
40-
RUN pip3 install -r /home/node/webthings/gateway/requirements.txt
41+
RUN pipx install cookiecutter && \
42+
pipx runpip cookiecutter install -r \
43+
/home/node/webthings/gateway/requirements.txt
4144

4245
USER node
4346
WORKDIR /home/node/webthings/gateway

README.docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# WebThings Gateway
22

3-
Docker image based on Debian Buster for running the
3+
Docker image based on Debian Bookworm for running the
44
[WebThings Gateway](https://github.com/WebThingsIO/gateway). The image
55
is built for AMD64, ARMv7, and ARMv8 (AArch64).
66

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ $ sudo apt install \
5858
libudev-dev \
5959
libusb-1.0-0-dev \
6060
pkg-config \
61-
python-six \
62-
python3-pip
61+
python3-six \
62+
python3-pip \
6363
$ sudo -H python3 -m pip install git+https://github.com/WebThingsIO/gateway-addon-python#egg=gateway_addon
6464
```
6565

docker/init.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ ln -sf "/usr/share/zoneinfo/$TZ" /etc/localtime
1111
# Run avahi-daemon in the background
1212
/usr/sbin/avahi-daemon -s -D
1313

14-
# Run the gateway
15-
export WEBTHINGS_HOME=/home/node/.webthings
14+
# If legacy .mozilla-iot directory exists, then move it to .webthings
15+
if [[ "$WEBTHINGS_HOME" == "$HOME/.webthings" &&
16+
-d "$HOME/.mozilla-iot" &&
17+
! -e "$HOME/.webthings" ]]; then
18+
mv "$HOME/.mozilla-iot" "$HOME/.webthings"
19+
fi
1620

17-
if [[ -d /home/node/.mozilla-iot && ! -e /home/node/.webthings ]]; then
18-
pushd /home/node
19-
ln -sf .mozilla-iot .webthings
20-
chown -R node:node .mozilla-iot
21-
popd
21+
# If .webthings directory doesn't exist then create it
22+
if [[ ! -e /home/node/.webthings ]]; then
23+
mkdir -p /home/node/.webthings
2224
fi
2325

24-
chown -R node:node "${WEBTHINGS_HOME}"
26+
# Give the Node user access to the .webthings data directory
27+
chown -R node:node /home/node/.webthings
28+
29+
# Run the gateway
30+
export WEBTHINGS_HOME=/home/node/.webthings
2531
su node -c "cd /home/node/webthings/gateway && ./run-app.sh"

run-app.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ run_app() {
4545
npm run "${start_task}" -- $args
4646
}
4747

48+
# If legacy .mozilla-iot directory exists, then move it to .webthings
49+
if [[ "$WEBTHINGS_HOME" == "$HOME/.webthings" &&
50+
-d "$HOME/.mozilla-iot" &&
51+
! -e "$HOME/.webthings" ]]; then
52+
mv "$HOME/.mozilla-iot" "$HOME/.webthings"
53+
fi
54+
4855
if ! is_container; then
4956
if [ ! -f .post_upgrade_complete ]; then
5057
./tools/post-upgrade.sh
@@ -53,20 +60,12 @@ else
5360
_node_version=$(node --version | egrep -o '[0-9]+' | head -n1)
5461
if [[ ! -f "${WEBTHINGS_HOME}/.node_version" ||
5562
"$(< "${WEBTHINGS_HOME}/.node_version")" != "${_node_version}" ]]; then
56-
cd "${HOME}/webthings/gateway"
5763
mkdir -p "${WEBTHINGS_HOME}/config"
64+
cd "${HOME}/webthings/gateway"
5865
./tools/update-addons.sh
59-
cd -
60-
echo "${_node_version}" > "${WEBTHINGS_HOME}/.node_version"
6166
fi
6267
fi
6368

64-
if [[ "$WEBTHINGS_HOME" == "$HOME/.webthings" &&
65-
-d "$HOME/.mozilla-iot" &&
66-
! -e "$HOME/.webthings" ]]; then
67-
mv "$HOME/.mozilla-iot" "$HOME/.webthings"
68-
fi
69-
7069
mkdir -p "${WEBTHINGS_HOME}/log"
7170

7271
if [ -f "${WEBTHINGS_HOME}/log/run-app.log" ]; then

tools/update-addons.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const migrate = require('../build/migrate').default;
2-
const db = require('../build/db').default;
1+
const migrate = require('../build/migrate');
2+
const db = require('../build/db');
33
db.open();
44

5-
const AddonManager = require('../build/addon-manager').default;
5+
const AddonManager = require('../build/addon-manager');
66

77
migrate()
88
.then(() => {

tools/update-addons.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22

3+
set -e -x
4+
35
export NVM_DIR="$HOME/.nvm"
6+
47
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
58

9+
610
node "$(readlink -f "$(dirname "$0")")/update-addons.js"

0 commit comments

Comments
 (0)