Skip to content

Commit 8f6d7f4

Browse files
authored
New entrypoint (#324)
* Add PubkeyAccessKeyTypes settings * Switch entrypoint to allow NR to run as root if needed This works round npm droping uid when running as root
1 parent b335cb8 commit 8f6d7f4

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

.docker/Dockerfile.alpine

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ RUN echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> /etc/ssh/ssh_config
4040
# package.json contains Node-RED NPM module and node dependencies
4141
COPY package.json .
4242
COPY flows.json /data
43+
COPY .docker/scripts/entrypoint.sh .
4344

4445
#### Stage BUILD #######################################################################################################
4546
FROM base AS build
@@ -97,4 +98,4 @@ EXPOSE 1880
9798
# Add a healthcheck (default every 30 secs)
9899
HEALTHCHECK CMD node /healthcheck.js
99100

100-
ENTRYPOINT ["npm", "--no-update-notifier", "--no-fund", "start", "--cache", "/data/.npm", "--", "--userDir", "/data"]
101+
ENTRYPOINT ["./entrypoint.sh"]

.docker/scripts/entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../docker-custom/scripts/entrypoint.sh

docker-custom/Dockerfile.custom

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ RUN echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> /etc/ssh/ssh_config
3939
# package.json contains Node-RED NPM module and node dependencies
4040
COPY package.json .
4141
COPY flows.json /data
42+
COPY scripts/entrypoint.sh .
4243

4344
#### Stage BUILD #######################################################################################################
4445
FROM base AS build
@@ -95,4 +96,5 @@ EXPOSE 1880
9596
# Add a healthcheck (default every 30 secs)
9697
# HEALTHCHECK CMD curl http://localhost:1880/ || exit 1
9798

98-
ENTRYPOINT ["npm", "start", "--cache", "/data/.npm", "--", "--userDir", "/data"]
99+
# ENTRYPOINT ["npm", "start", "--cache", "/data/.npm", "--", "--userDir", "/data"]
100+
ENTRYPOINT ["./entrypoint.sh"]

docker-custom/Dockerfile.debian

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ RUN echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> /etc/ssh/ssh_config
4040
# package.json contains Node-RED NPM module and node dependencies
4141
COPY package.json .
4242
COPY flows.json /data
43+
COPY scripts/entrypoint.sh .
4344

4445
#### Stage BUILD #######################################################################################################
4546
FROM base AS build
@@ -96,4 +97,4 @@ EXPOSE 1880
9697
# Add a healthcheck (default every 30 secs)
9798
# HEALTHCHECK CMD curl http://localhost:1880/ || exit 1
9899

99-
ENTRYPOINT ["npm", "start", "--cache", "/data/.npm", "--", "--userDir", "/data"]
100+
ENTRYPOINT ["./entrypoint.sh"]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
trap stop SIGINT SIGTERM
4+
5+
function stop() {
6+
kill $CHILD_PID
7+
wait $CHILD_PID
8+
}
9+
10+
/usr/local/bin/node $NODEOPTIONS node_modules/node-red/red.js --userDir /data $FLOWS &
11+
12+
CHILD_PID="$!"
13+
14+
wait "${CHILD_PID}"

0 commit comments

Comments
 (0)