Cache gems for every build on GitLab Runner

us flag

I have a GitLab Runner installed on a Ubuntu server. It uses 'docker' executor.

I want every CI job which executes on this runner to use the same Ruby gems cache, to prevent downloading from the same version several times in a row.

There seems to be two solutions:

  1. Use cache: instruction in .gitlab-ci.yml. I don't like that because I would have per-project cache instead of single cache for all projects. Also, I don't want to update a dozen of .gitlab-ci.yml files if that could be evaded.

  2. Use Gitstash as transparent proxy. That would still require to modify Dockerfiles of all projects with proper bundle config ... instructions. In this variant I don't know how to access Gitstash (which I would like to run at the same machine where gitlab-runner is working) from inside the build phase of containers.

Is there a third solution? What's best to do here?


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.