Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating Telegram Nodes into Node-RED #251

Open
goderz opened this issue Feb 3, 2024 · 3 comments
Open

Integrating Telegram Nodes into Node-RED #251

goderz opened this issue Feb 3, 2024 · 3 comments

Comments

@goderz
Copy link

goderz commented Feb 3, 2024

Hello,

I'm looking to integrate Telegram nodes into Node-RED.

Initially, during the Docker container setup, I overlooked selecting the Telegram Node in the installation options. I later attempted to include it through the Build Menu and proceeded to restart all the containers, but this didn't seem to have any effect. Attempting to add Telegram nodes from the Node-RED Palette results in errors, as shown in the attached screenshot.

Could someone guide me on how to successfully integrate Telegram nodes and potentially other nodes in the future? Any assistance would be greatly appreciated.

Thank you!

Zrzut ekranu 2024-02-03 220801

@Paraphraser
Copy link
Contributor

Can I get you to do two things, please:

  1. Read * * THIS PROJECT IS DORMANT * * #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.

@goderz
Copy link
Author

goderz commented Feb 4, 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! :)

@Paraphraser
Copy link
Contributor

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants