Ability to specify cache sources during image build

Right now Tutor doesn’t provide any option to provide a cache source during the image build. Docker has a way to provide an external cache source. We should allow setting --cache-from option in the tutor image build command.

This will allow users to leverage advanced docker build-cache via buildkit. I’ve done some experiments with it and it does speed up a lot during subsequent builds.

I will be happy to open a PR if you guys think this is a good optimization.

cc @maintainers


Hey @shimulch,
I am all for adding the --cache-from option to tutor images build. But let me tell you about my dilemma: ideally, I would like to transparently forward all docker build options passed to tutor images build, pretty much like it is done in tutor local run. My problem is that the tutor images build command already has a variadic argument. This variadic argument makes it possible to build multiple images at once:

tutor images build openedx forum ...

I would like to be able to capture all the extra arguments that come before the list of images and transparently forward them to docker build:

tutor images build --opt1 arg1 --opt2=arg2 openedx
# calls: docker build  --opt1 arg1 --opt2=arg2 -t docker.io/overhangio/openedx:12.0.4 ~.local/share/tutor/env/build/openedx

My problem is that to enable this feature we will need two variadic arguments, which is impossible. The alternative is to explicitly define all the docker build options that are actually supported by tutor images build. But this list is bound to become bigger and bigger. And everytime we add a new option, it needs to be properly documented.

A possible solution would be to parse extra docker build arguments as an environment variable (with ;-separated values). For instance:

export TUTOR_DOCKER_BUILD_ARGS="--opt1;arg1;--opt2==arg2;--cache-from=somewhere"
tutor images build openedx forum

Would that work for you? If yes, please feel free to open a PR.

1 Like