Is it possible to have a multi-container multi-device setup with a single code base?
I’ve got a distributed application that for each installation runs on three different devices (2 x RPi3, 1 x Intel NUC). Per now, we push to two different Balena Apps (one for each device type). We use two Dockerfiles (differentiated by dev suffix), and for the RPi’s we use device service variables to differentiate between the two RPi3’s. For now, this setup is sufficient; we can maintain a single code base for all devices, and deploying new code is done by
balena push RPi3App && balena push NUCApp.
In the not so distant future, we’d like to split the NUC Dockerfile into three services, and also add a new service to one of the RPi’s. But we still strongly wish to maintain only one code base.
The first solution I’ve tried is using separate directories – one for each device – for the Docker config, and then using
balena push -s <dir> <appname> for deployment. However, this does not work, since the build context lies in the parent directory of the docker config directory.
The next solution I can think of is to ditch the Balena builder. That is, using
balena build to create the images, and then
balena push to deploy them. That should work, but I haven’t tried it yet.
The nicest solution would, IMO, be if Balena supported multiple Docker Compose files. Then I could create one
docker-compose.intel-nuc, and then
balena push would determine which Docker Compose file to use for which device type.