mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 16:56:33 +00:00
fix(nodered): seed /data/settings.js via entrypoint wrapper
The /data named volume hides anything Dockerfile COPYs into /data, so the previous CMD override pointing at /usr/src/bf-settings.js didn't help — Node-RED's launch script still looks for /data/settings.js by default, which doesn't exist after the volume overlays. Solution: entrypoint wrapper copies /usr/src/bf-settings.js to /data/settings.js on first boot when missing, then exec's npm start. Subsequent boots keep the user-edited version in the volume.
This commit is contained in:
parent
6473f0fc95
commit
7baa1a07f9
2 changed files with 23 additions and 4 deletions
|
|
@ -11,9 +11,12 @@ USER root
|
|||
# Copy our nodes into a path outside /data (which is volume-mounted)
|
||||
COPY nodered /usr/src/betterframe-nodes
|
||||
|
||||
# Settings file at a non-/data path so the nodered-data volume doesn't
|
||||
# overlay it. CMD passes --settings to point Node-RED at it.
|
||||
# Settings template + entrypoint that seeds /data/settings.js on first boot
|
||||
# (the /data named volume hides anything we COPY directly there, so we have
|
||||
# to plant the file after the volume mount comes up).
|
||||
COPY deploy/docker/nodered-settings.js /usr/src/bf-settings.js
|
||||
COPY deploy/docker/nodered-entrypoint.sh /usr/local/bin/bf-nodered-entrypoint
|
||||
RUN chmod +x /usr/local/bin/bf-nodered-entrypoint
|
||||
|
||||
# Install deps for the nodes
|
||||
RUN cd /usr/src/betterframe-nodes && \
|
||||
|
|
@ -22,5 +25,5 @@ RUN cd /usr/src/betterframe-nodes && \
|
|||
|
||||
USER node-red
|
||||
|
||||
# Override the default CMD to use the baked settings.js.
|
||||
CMD ["npm", "start", "--cache", "/data/.npm", "--", "--userDir", "/data", "--settings", "/usr/src/bf-settings.js"]
|
||||
ENTRYPOINT ["/usr/local/bin/bf-nodered-entrypoint"]
|
||||
CMD []
|
||||
|
|
|
|||
16
deploy/docker/nodered-entrypoint.sh
Executable file
16
deploy/docker/nodered-entrypoint.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env sh
|
||||
# Seed /data/settings.js with our BF defaults on first boot.
|
||||
# /data is volume-mounted, so the COPY in the Dockerfile gets hidden
|
||||
# unless we plant a copy after the mount comes up.
|
||||
set -eu
|
||||
|
||||
DATA=/data
|
||||
TPL=/usr/src/bf-settings.js
|
||||
|
||||
if [ ! -f "$DATA/settings.js" ]; then
|
||||
echo "[bf-nodered] seeding $DATA/settings.js from $TPL"
|
||||
cp "$TPL" "$DATA/settings.js"
|
||||
fi
|
||||
|
||||
# Exec the upstream nodered entrypoint args verbatim.
|
||||
exec npm start --cache /data/.npm -- --userDir /data "$@"
|
||||
Loading…
Reference in a new issue