Is it possible to add a setting to cache my docker image anywhere in the travis configuration ? Mine is a bigger docker image and it takes a while for it to download.
Any suggestions ?
The concept of Docker images comes with immutable layers. Every command you execute results in a new layer that contains the changes compared to the previous layer. All previously built layers are cached and can be reused.
Travis CI builds can run and build Docker images, and can also push images to Docker repositories or other remote storage. Then you can add - docker commands to your build as shown in the following examples. We do not currently support use of Docker on macOS.
Docker build-with-cache action. This action builds your docker image and caches the stages (supports multi-stage builds) to improve building times in subsequent builds.
Still the bottom line is: Jenkins does not cache automagically for you. Caching is inside the scope of the build tool(s) that you are using. You have to take care to incorporate that properly to your CI environment's needs. But of course it is possible to achieve.
Simplest solution today (October 2019) is to add the following to .travis.yml
:
cache: directories: - docker_images before_install: - docker load -i docker_images/images.tar || true before_cache: - docker save -o docker_images/images.tar $(docker images -a -q)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With