Installing Node Red on Brainypis the Right Way

by dhruvarora561 in Circuits > Computers

120 Views, 0 Favorites, 0 Comments

Installing Node Red on Brainypis the Right Way

Node-red-icon.png

Node-RED is a tool for wiring together hardware devices, APIs and online services. It is a browser based tool, it can deploy in seconds using a click of a button. It also features a rich text editor which allows JavaScript functions to be created.

It is built on node.js, which allows it to take full advantage of its event-driven, non-blocking model. This allows it to be able to run on devices like BrainyPI or RaspberryPi.

Supplies

  1. BrainyPi or Raspberry pi
  2. Keyboard
  3. Mouse
  4. Internet(Wireless or Ethernet)
  5. Monitor(Optional)

Docker Installation

1.1 Checking if docker is installed or not

sudo docker run hello-world

The above command runs a docker container, prints a message and exits.

1.2 If docker is not installed. Then follow the steps on the official docker page to complete the installation.


Creating Docker-compose

Docker-compose is a tool which is used to spin up a docker container using one single command. We create a yaml file and then use it to start the container.

2.1 Start by creating a directory

mkdir ~/node-red

This directory will hold our docker-compose file as well as will be used to store configuration files as docker uses volumes to store data.

2.2 Changing to the directory

cd ~/node-red

2.3 Creating docker-compose. Now, we will create the yaml file to write the configuration of docker containers.

nano docker-compose.yml


Writing Docker-compose

Now, that we have created a docker-compose file, we now need to write the file. Copy and paste the following in the terminal

version: "3.7"

services:
node-red:
image: nodered/node-red:latest
environment:
- TZ=India/Kolkata
ports:
- "1880:1880"
networks:
- node-red-net
volumes:
- node-red-data:/data

volumes:
node-red-data:

networks:
node-red-net:

3.1 Here, if the port 1880 is already in use. Then It can be changed to any port which is open. docker-compose follows HOST:CONTAINER format for port mapping. Refer to this for more information.

3.2 In the volumes section the location of the volume can be changed.

3.3 timezone should also be changed accordingly.

3.4 Press `ctrl+x` and then type `y` and hit `enter`.

Creating and Running the Container

The hard part is now done. Now, all we need to do is run the command below and docker will start pulling the images and the create the container and then run it.

sudo docker compose up -d

4.1 It will take some time complete. After, it finishes open a browser and navigate to the address below

http://localhost:1880

4.2 And then you will be greeted with the welcome screen of node-red.


Node-red Web GUI

Screenshot_20230203_150744.png

Congratulations! You made it!