Node-Red running with balena

Hi,

Apologies for the onslaught of Newbie questions.

I’m having some issues getting my Node-Red up and running with Balena. When I git push my projects folder I am getting this error:

I’m trying to use this article to set this up but it is outdated, and I don’t really understand how to use Dockerfiles so I am struggling to follow it properly.

Can anyone help me?

Thanks,
Gregor

Hey @gregorr1, could you share the url of the project you are trying to push?
I would like also to invite you to install the balena-cli instead of using the git push method, you can check the steps to install it here: https://github.com/balena-io/balena-cli/blob/master/INSTALL.md

Thanks

Hi @dansku I’ve added the balena-cli now. What URL is it you’re looking for? Is it my application URL?

What is the command to try and push from balena-cli?

Hey there! My colleague is referring to the GitHub URL of the project you are trying to push, assuming it’s public. Regarding the push command, that should be balena push (https://www.balena.io/docs/reference/cli/#push-applicationordevice)

The GitHub URL is private at the moment - I can send copies of our docker file etc. However, they are copied from this article.

No worries! Lets try balena push as @dansku suggested above and see if that makes any difference!

Hi @jviotti we ran a balena push as suggested, but this gave the same errors. We have since removed this line from our docker file (copied from the article I sent previously):

pip3 install sense-hat rtimulib pillow

We now have successfully been able to push to the Balena.

The next step is now sorting out our docker file so that our Node-Red program starts automatically. Can you point me in the right direction?

Thanks

I’m glad you made it push! With regards to Node Red, have you checked our Node Red example project https://github.com/balena-io-projects/balena-node-red?

Hi @jviotti, I’ve had a look at the example project but I’m not sure the best way to use this to solve my issues. The directories seem to be laid out very different from mine - I’m using the node-red projects feature to manage my git directory. I tried copying over some of the files that I saw for example the Dockerfile.template and the docker-compose.yml but when I ran the balena push it said it couldn’t find a dockerfile.

What is the best way to make sure I have all the necessary parts of the directory, without changing it so much that the node-red projects breaks?

Thanks,
Gregor

Hi,

Can you please share with us the content of your Dockerfile.template/docker-compose.yml that you use?

Currently, I’m just using a Dockerfile. When I copied the Dockerfile.template it wouldn’t let me push so I copied the contents to a file called “Dockerfile” and changed the device to raspberrypi4, this wouldnt push so I tried it with raspberrypi3 and it let me push to balena.

###
# Build step
###
FROM balenalib/raspberrypi3-debian-node:12-stretch-build as build

RUN JOBS=MAX npm install -g --production --unsafe-perm \
       node-red \
       node-red-admin \
       node-red-contrib-balena

###
# Runtime image
###
FROM balenalib/raspberrypi3-debian-node:12-stretch-run

RUN apt-get update && apt-get install -yq --no-install-recommends \
  rpi.gpio \
  python-dev \
  python-rpi.gpio \
  && apt-get clean && rm -rf /var/lib/apt/lists/*

# Defines our working directory in container
WORKDIR /usr/src/app

# Copy over the files created in the previous step, including lib/, bin/
COPY --from=build /usr/local/bin /usr/local/bin
COPY --from=build /usr/local/lib/node_modules /usr/local/lib/node_modules

# This will copy all files in our root to the working  directory in the container
COPY . ./

# server.js will run when container starts up on the device
CMD ["bash", "/usr/src/app/start.sh"]

So you can build it now then what is your issue here?
Our example use docker-compose.yml so you might need to change the COPY . ./ command to correct directory if you use Dockerfile instead, otherwise it will break the CMD ["bash", "/usr/src/app/start.sh"] as start.sh doesn’t exist

Okay brilliant thanks, I’ve changed the COPY so I’ll try push that to the devices and see if it starts the Node-red.

The node red still isn’t starting, I checked the logs on the balena dashboard and got this:

Any ideas how to fix this? I cant see a ResinApp.sh in my project folder so I’m not sure where it is from.

Thanks,
Gregor

Looks like Node-red isn’t installed properly, can you please share your Dockerfile or grant support access so I can have a look?

hi @nghiant2710 How do I grant support access?

You can follow the guide in our docs here https://www.balena.io/docs/learn/manage/actions/#grant-support-access-to-application to grant support access

That should be it done now

Can you please send us your device UUID?

Device uuid is f8c5a2f211ac5a4ef4015b3f93b234b8

I’ve also noticed that it keeps trying to update my device from release d48e7e6 to a2e744a, but it keeps reverting and trying again.