I’ve been doing "balena push which seems to do the building of the image on the Balena Cloud. Now it looks like there’s an option to do a local build. What is the advantage?
It seems to me that local build would use my attached raspberry pi to do the docker build. The pi is much slower so I am not seeing what the advantage is. Can someone help me understand? Thanks!
hi @pitosalas thats a great question. You can read more about the local development mode here: https://www.balena.io/blog/living-on-the-edge-with-livepush-and-other-cli-improvements/ but the TL;DR is that with local push even though you have less CPU we have done a few clever things to allow live reloading layers of the build, so for example if you do an npm install
or pip install
on the build servers, docker would reinstall every single npm
or pip
package again, this is because each line in a dockerfile creates a brand new layer on top of the other, so a change to the layer results in completely removing that layer. In local push this is not the case and the “cache” in those past layers of builds is kept and so you would only install the packages that changed since the last build. This is even more useful if you are using a language like rust or go where the compiler does incremental builds.
A pattern I often use for my personal projects is to do a base build of my project on the builder using balena push
especially if i am installing something like openCV and I know its CPU intensive. Then once that is built and pulled down to my device I switch it into local mode (https://www.balena.io/docs/learn/develop/local-mode/) and do the rest of my development there as that is much faster as you have the incremental changes and no need to wait for upload to registry and download to device.
Hope that helps a bit to understand local mode
1 Like