i want to share builds with other people in my team. Therefore i set up a docker registry that stores the build images. Sadly when other people are pulling the image the cache seems not to be used.
Since our builds take ~3h on a fast workstation (CUDA, OpenCV, Tensorflow, …) caching is very usefull.
How to reproduce the behaviour
push a build image to you registry docker tag myapp_main registry.yourdomain.com/bla docker push registry.yourdomain.com/bla:latest
prune all local images docker system prune --all
pull image docker pull registry.yourdomain.com/bla:latest docker tag registry.yourdomain.com/bla:latest myapp_main:latest
do a new build without changing the dockerfile or its resources
-> Cache is not used
Do you have any idea on how to tag the images, in order to get chaching to work?
Hi,
Can you provide us with more details on how you build the image in the first place and when the cache is used? Also is this an emulated build? In which case we start a docker daemon in a qemu to perform cross architecture builds.
Hi Frederic, the built images would be stored in your local docker registry once they are built. But I think most likely the CLI won’t by default use all the on disc images that exist while building. docker used to do this automatically but due to some cache poisoning exploits they disabled automatically using all images and only use images that were build by the engine on your host. So one needs to pass a specially flag that tells the build to use all the available images, or a list of images as cache. I suspect the cli deploy command is not using that flag when building, but it should be possible to add.
The --cache-from option is what i looked into, too. But i just could not figure out, where i could hardcode it into the balena-cli for a quick fix and later do a Pull Request with a better implementation. I am no expert in coffee script and the project seems quiet complex to understand. Therefore i am looking for file you can point me to, that describes how to sett the build options with docerode or similar, so i can work my way from there.
Yeah, I have been trying to find where the options are set as well, but have had no luck and also have little to zero coffee experience, so think we need to wait until the CLI team come online, they will be able to point us in the right direction super fast.
Just as information for the CLI team. The build argument needs to be parsed through dockerode. Since it isusing the docker api docker_build
The cachefrom option is defined as string: JSON array of images used for build cache resolution..
Therefore i am looking for file you can point me to, that describes how to set the build options with dockerode or similar, so i can work my way from there.
I will try it out in the next hours, since this feature is very important to us
We spend about 8h a day on building images and this feature can cut it down to ~1h a day
Yes i tried it and it does not seem to work. My current guess is, that the Dockerfile will get treated similar to how docker compose gets treated, therefore we might need to implement something like this.
@Langhalsdino, thank you for the feature suggestion and for helping with the testing. The --cache-from option for the balena build and balena deploy commands was released in CLI version 11.26.0.
For the benefit of others reading this thread, it implements the same feature documented for the docker build --cache-from option, “Specifying external cache sources”: