1ac9ef948b
NR's automatic package.json install at container start was slow and required internet. Move npm install to image build time, preserve the installed node_modules via an anonymous volume so the bind mount of ./nodered:/data doesn't clobber them.
28 lines
1.2 KiB
Docker
28 lines
1.2 KiB
Docker
# Node-RED container with Dashboard 2.0 baked in
|
|
# Build once; restart containers freely. NR's automatic package.json install
|
|
# at boot is slow and requires internet; this Dockerfile install is cached
|
|
# and reproducible.
|
|
#
|
|
# Docker volume pattern: ./nodered:/data is a bind mount (settings.js,
|
|
# flows.json, start.sh, package.json are host-owned); /data/node_modules
|
|
# is an anonymous volume so the bind mount doesn't clobber the installed
|
|
# deps. Docker copies the image's node_modules into the volume on first start.
|
|
|
|
FROM nodered/node-red:5.0.0
|
|
|
|
# Install Dashboard 2.0 (and any future deps) at image-build time.
|
|
# Versions are pinned in infra/nodered/package.json for reproducibility.
|
|
COPY package.json /data/package.json
|
|
WORKDIR /data
|
|
RUN npm install --omit=dev --no-audit --no-fund \
|
|
&& chown -R 1000:1000 /data/node_modules \
|
|
&& echo "[Dockerfile] installed @flowfuse/node-red-dashboard"
|
|
|
|
# start.sh handles the SPA base-href patch (idempotent: grep guard).
|
|
# Chmod so the compose `user: 1000:1000` can run it.
|
|
COPY start.sh /data/start.sh
|
|
RUN chmod +x /data/start.sh
|
|
|
|
# Reset to NR's working dir; userDir is /data via the compose volume mount.
|
|
WORKDIR /usr/src/node-red
|