Adding Libraries to Existing Projects

Greetings Community!

This is as much a ‘general’ / architectural question about the balena environment as it is specifically about the balenaSound project. I did some quick searching of the forums, and referred to the ‘similar’ topics suggested - but didn’t quite find a match. Totally happy with any RTFM links to documentation I may have overlooked :slight_smile:

My question is this:

When adding additional libraries or components to a balena node - is there a recommended approach? Given my experience with the holiday lighting controller, and it’s 4 containers - I infer that for larger, discrete components, which communicate over network APIs - unique containers for each stand-alone component or service makes sense, giving each it’s own, decoupled lifecycle.

What if I want to add some libraries for a particular peripheral (a sensor, or a pHAT)? Can in point: I’ve got an Unicorn HD LED HAT on the Pi onto which I’m deploying balenaSound - and thought it might be fun to include a spectrum analyzer, or light show, or even track info…

I’ve got the repo cloned: Is it as simple as installing the libraries/packages I want in my local copy, and then:

$ balena push

?

Thanks in advance!

Hi Billy,

The ‘holiday lighting controller’ you are referring to is I believe this repo which is a multi-container balena application (with four containers as you point out). You can get started with multi-container applications by checking out the documentation on multiple containers. As you’ve seen from the holiday lighting controller application, each service runs in its own container. So to add a new service to an existing multi-container application you will add a new container by adding a top-level folder inside which all your new container’s source files will reside, specifically including a Dockerfile.template for that service/container. Then it’s just a case of editing the top-level docker-compose.yml file with the appropriate configuration in a new entry under the services section. Then you can run balena push!

Do feel free to post here with specific details of the service you’re wanting to integrate and other folk may be able to help with the specific configuration and dependencies required for that service.