balena-labs-projects / balena-node-red

a node-red application with balena-supervisor support, can be managed remotely via balena publicURL
Apache License 2.0
60 stars 62 forks source link

Multicontainer support #11

Closed esaheiskanen closed 5 years ago

esaheiskanen commented 6 years ago

Hi! Resin.io released support for multiple docker container. I tried to run this as separate container, without any luck. Is there some kind of modifications needed to make this work?

https://docs.resin.io/learn/develop/multicontainer/

curcuz commented 6 years ago

Hey @esaheiskanen if you push this project as-is, it will work the way it used to before the multi-container release. If you instead are trying to deploy this among other services as a multi-container app, there might be minor tweaks to make - I will be working on this next week and make sure to update this thread

esaheiskanen commented 6 years ago

Great news thanx!

-- Esa Heiskanen

From: Curinga Carlo Maria notifications@github.com notifications@github.com Reply: resin-io-projects/resin-node-red reply@reply.github.com reply@reply.github.com Date: 13 March 2018 at 0.18.27 To: resin-io-projects/resin-node-red resin-node-red@noreply.github.com resin-node-red@noreply.github.com CC: esaheiskanen esa@applari.fi esa@applari.fi, Mention mention@noreply.github.com mention@noreply.github.com Subject: Re: [resin-io-projects/resin-node-red] Multicontainer support (#11)

Hey @esaheiskanen https://github.com/esaheiskanen if you push this

project as-is, it will work the way it used to before the MultiContainer release. If you instead are trying to deploy this among other services as a multicontainer app, there might be minor tweaks to make - I will be working on this next week and make sure to update this thread

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/resin-io-projects/resin-node-red/issues/11#issuecomment-372481568, or mute the thread https://github.com/notifications/unsubscribe-auth/AFzuct5MgaGlzgMeGlOVjS99nRg3MPSOks5tdvQzgaJpZM4Snxwn .

esaheiskanen commented 6 years ago

Any news on this?

tnagels commented 6 years ago

I am working on this as we speak for a home automation project. It requires some edits, one of which is that you need to fix the name of the flows file as the hostname may change between updates (loosing your flows). Also some mapping for the volumes needs to be done.

I will put it out in the open when I'm confident I have the basics right, currently still struggling with gpio... (And, more importantly, I need to do the right attribtions & licencing stuff)

curcuz commented 6 years ago

@tnagels not sure I follow - The hostname by default is always the short UUID of the device

curcuz commented 6 years ago

@esaheiskanen playing with it now as it is without issues, can you share your compose file?

tnagels commented 6 years ago

@curcuz What I saw is that when updating the container for node-red, the last part of name of the file containing the flows would change. As per the documentation this is the hostname. So, I gave it a fixed name:

// The file containing the flows. If not set, it defaults to flows_<hostname>.json flowFile: 'flows_resin.json',

That fixed it for me.

tnagels commented 6 years ago

And by now I also fixed the IO problems. Once I have the documentation in order, I'll open the repo. For now what I can share is that in your docker compose you need to add cap_add: - SYS_RAWIO devices: - "/dev/mem:/dev/mem" - "/dev/gpiomem:/dev/gpiomem"

and in the template also apk add the following packages: python-dev py-rpigpio

esaheiskanen commented 6 years ago

Thanx! I’ll give this a shot when i get back home. Could someone post a working sample?

tnagels commented 6 years ago

@esaheiskanen working on it. With what I have now, output seems to be working but input does not. Need to fix that first.

esaheiskanen commented 6 years ago

@tnagels I played around a bit and I ended up building resin-node-red as is to docker hub. THis way i managed to make this up and running. Everything seemsto be working fine, but resin.io blink led is not working.

I get error "An error occurred: Error: Invalid URI "undefined/v1/blink?apikey=undefined""

Also it seems that RPi-GPIO is not installed [warn] Cannot find Pi RPi.GPIO python library but if i remember correctly that was the case with single container installation too.

tnagels commented 6 years ago

I came across both.

Hope this makes sense to you.

esaheiskanen commented 6 years ago

thanx.

i found another way to make resin.io blink work by installing node-red node npm i node-red-contrib-resinio

alternative to privileged: true was mentioned in documentation

`devices:

Anyhow, its working now!

Now i'm considering that maybe all RPi hardware related stuff (gpio, 1wire, etc) should be installed in separate container and build rest api to interact. Don't know yet if this is worth the effort though.

tnagels commented 6 years ago

Hmmm. I should check that out then. Did you also try working with inputs? Because that is what not worked for me with the alternative you mention.

esaheiskanen commented 6 years ago

no, not yet. I'am actually using iono-pi https://www.sferalabs.cc/iono-pi/ which has its own helper utility written in C (1wire, relays and analog) and it needs rasbian to be build https://github.com/sfera-labs/iono-pi-c-lib so that would be the other container running. I have two options: link containers and call utility from otehr container or build single image with resin.io raspian, node-red and build iono-pi helper utility. We'll see.

tnagels commented 6 years ago

I'm using the same device. but I chose not to use the helper and go direct as there are nodes available in node-red to do this. It is working, but need to run in privileged (yikes....) That said, I won't be using any of the iono's special features, just plain I/O.

esaheiskanen commented 6 years ago

Well thats a great coincidence. I will need analog input and 1wire. I read through helper utility source and i could be rewritten to nodejs, but maybe later. I think I will try to build single image first.