Git Product home page Git Product logo

Comments (3)

Paraphraser avatar Paraphraser commented on September 21, 2024 1

You're welcome. Don't forget the docker system prune -f. Each time you use the --build flag, it creates a new image and leaves the old image dangling. The prune command cleans-up all those dangling bits and pieces. Leaving one or two old images lying about is no big deal but if you never tidy up then, eventually, you can run out of disk space (more important if you're running from SD).

from iotstack.

Paraphraser avatar Paraphraser commented on September 21, 2024

Can I get you to do two things, please:

  1. Read #194 (explains why this is the wrong repo and how you should be using SensorsIot/IOTstack instead); and then
  2. Read Component Management in the Node-RED section of the SensorsIot/IOTstack Wiki.

The short answer to your question is that the "best" way to add/remove add-on nodes is to edit:

~/IOTstack/services/nodered/Dockerfile

A somewhat longer answer involves explaining that the Dockerfile used by IOTstack's service definition for Node-RED has gone through several revisions.

If you (a) use SensorsIot/IOTstack (migrating to that repo if necessary), and (b) do something which "resets" Node-RED (eg remove and re-add Node-RED), you will wind up with a service definition that looks like this:

  nodered:
    container_name: nodered
    build:
      context: ./services/nodered/.
      args:
      - DOCKERHUB_TAG=latest
      - EXTRA_PACKAGES=
    restart: unless-stopped
    user: "0"
    environment:
    - TZ=${TZ:-Etc/UTC}
    ports:
    - "1880:1880"
    volumes:
    - ./volumes/nodered/data:/data
    - ./volumes/nodered/ssh:/root/.ssh

plus a Dockerfile that looks like this:

# reference argument - omitted defaults to latest
ARG DOCKERHUB_TAG=latest

# Download base image
FROM nodered/node-red:${DOCKERHUB_TAG}

# reference argument - omitted defaults to null
ARG EXTRA_PACKAGES
ENV EXTRA_PACKAGES=${EXTRA_PACKAGES}

# default user is node-red - need to be root to install packages
USER root

# install packages
RUN apk update && apk add --no-cache eudev-dev ${EXTRA_PACKAGES}

# switch back to default user
USER node-red

# variable not needed inside running container
ENV EXTRA_PACKAGES=

# add-on nodes follow

RUN cd /usr/src/node-red && npm install --save  node-red-configurable-ping
RUN cd /usr/src/node-red && npm install --save  node-red-contrib-boolean-logic
RUN cd /usr/src/node-red && npm install --save  node-red-contrib-influxdb
RUN cd /usr/src/node-red && npm install --save  node-red-dashboard
RUN cd /usr/src/node-red && npm install --save  node-red-node-pi-gpiod
RUN cd /usr/src/node-red && npm install --save  node-red-node-rbe

Personally, I think the structure of the last six lines sucks because:

  1. The cd commands are redundant (that's already the working directory);
  2. The --save flags are redundant (have been ignored by npm for ages); and
  3. Each distinct RUN command creates a new layer in the final local image which just adds overhead.

Here's what the last part of my Dockerfile looks like:

…
# add-on nodes follow

RUN npm install \ 
  node-red-node-pi-gpiod \
  node-red-dashboard \
  node-red-contrib-influxdb \
  node-red-contrib-boolean-logic \
  node-red-node-tail \
  node-red-configurable-ping \
  node-red-node-email \
  node-red-contrib-boolean-logic-ultimate \
  node-red-contrib-chartjs \
  node-red-contrib-md5 \
  node-red-contrib-moment \
  node-red-contrib-pushsafer

Anyway, suppose I wanted to add another package. I'd add a \ continuation to the last line followed by the new package. For example:

…
  node-red-contrib-pushsafer \
  node-red-contrib-simpletime

and then run:

$ cd ~/IOTstack
$ docker-compose up --build -d nodered
$ docker system prune -f

Hope this helps.

from iotstack.

goderz avatar goderz commented on September 21, 2024

Okay, it's working for me now. Here's what I did:

I followed these instructions:
image
from this section:
https://sensorsiot.github.io/IOTstack/Basic_setup/#when-dockerfile-changes-local-image-only

So basically, I executed the last two commands mentioned in your post. Thank you! :)

from iotstack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.