Submit Your Ideas

We want to hear from you - vote for the features and improvements you'd most like to see, or submit your own ideas if you don't find them already listed.

Support caching by docker image tag

Idea

Add a .Docker cache-key similar to the following:

  - save_cache:
          key: v1-build-cache-{{ .Docker }}
          paths: "_build

This would cause the cache to be invalidated whenever the docker SHA-256 of an image changes.

 

The common use case is when you have a docker image that's something like:

docker:
      - image: circleci/elixir:1.5

 

Then, when circleci updates the docker image to have a newer version of elixir, or otp, then compiled files have a mismatch. They were built (and cached) for one version of elixir, but are now running on an incompatible

version.

 

Adding the docker version as a key allows authors to make sure that environment-specific-files are only cached while the dockerfile remains the same.

 

Thank you!

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • Jul 12 2018
  • Future consideration
  • Attach files
  • Admin
    Nathan Dintenfass commented
    July 14, 2018 07:59

    What if, instead, you could parameterize the tag you want to use and also build your cache key from that? Then your executor declaration might look like:

    docker:
    - image: circleci/elixir:<< parameters.dockertag >>

    and then your cache key might look like:

      - save_cache:
              key: v1-build-cache-<< parameters.dockertag >>
              paths: "_build

     

    The above (or something a lot like it) will soon be possible in config, so curious if that would suffice?

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    July 14, 2018 08:09

    Hi @Nathan Dintenfass
    Unfortunately that won't solve the issue.


    The problem additionally happens when same docker tag to be overwritten.

    E.g. this is the actual scenario I have today:
    day 1: Building with circleci/elixir:1.6 works
    day N: Elixir 1.6.7 is released. circleci updates their docker images, and circleci/elixir:1.6 picks up the 1.6.7 binary

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    July 14, 2018 08:10

    ^^ the old _build cache doesn't work across elixir versions and builds start failing. This doesn't happen with every transition, but _has_ happened across OTP versions