Pipeline caching #2295
Replies: 4 comments 12 replies
-
This proposal makes some kind of sense to me. I find myself having to create special-purpose Docker containers with base dependencies for CI to run faster. There is another wish to have a way to cache package downloads/compilations (for e.g. Cargo), since that takes a long time on my CI and outweighs the build time of my project (also wasting energy/time/...). I tried setting up MinIO and sccache but it was pretty clunky and didn't work that well. I wish there was a nicely-integrated built-in method. |
Beta Was this translation helpful? Give feedback.
-
ProposalAs caching needs to work for different backends (docker, kubernetes, local, ssh, ...) it would probably be the best to allow the backends to internally map the cache volume to their supported system. configsteps:
restore-cache:
image: awesome-volume-cacher
settings:
cache_key: 123
volumes:
- name: cache
path: /cache
build:
image: node
commands:
- npm install
volumes:
- name: cache
path: /cache
save-cache:
image: awesome-volume-cacher
settings:
cache_key: 123
volumes:
- name: cache
path: /cache
volumes:
- name: cache backend supportdocker & kubernetes
local & ssh
problems & open questionsmultiple agents supportThere could be an issue that the volume doesn't exists on the agent. We could therefore add logic to the cache plugin or the backend directly to download non existing volume data from a s3 bucket. space qutoasThere need to be a way to restrict volume sizes cache cleanup / expirationHow can we easily define a volume expiration date |
Beta Was this translation helpful? Give feedback.
-
I have implemented a lot of caching for my woodpecker pipelines at work. I feel, most of the cache requirements can be solved by a plugin, a volume mount, and a shared storage across agents (using an NFS server, or maybe S3FS?). The only annoying thing that I encountered throughout the caching journey is that I have to mark all the pipelines trusted in which I want to mount the cache volume. Just a thought: can the problem statement be reduced to "finding a better way to allow mounting cache volumes in caching plugins without needing to be trusted?" |
Beta Was this translation helpful? Give feedback.
-
I would suggest using as simple as a stick solution - pull through cache. It is completely independent from CI. If you can't afford Artifactory or Nexus, you can set up Nginx proxy as well as specialized tools (goproxy, athens for This is example config for Nginx and Go:
This works for Node as well as for APK, DEB, RPM (with little adjustments). I believe it will work for other package managers like Cargo and Maven.
It would be even easier, when #3723 is merged. |
Beta Was this translation helpful? Give feedback.
-
Clear and concise description of the problem
Caching is a issue often talked about. It would save a lot of resources if dependencies for projects are not built every time, but only run from a certain point on.
Suggested solution
There is already a feature request in #758 that might try to achieve something similar, but it sounds focused on results, not prepare steps.
My proposal is the following: For every pipeline stage, there is an optional "refresh: " parameter, that defines how often this needs to be rebuilt. For example, when dependencies change frequently, you can specifiy "refresh: 1d". If your prepare step is used seldom, you can rebuilt it every 14d.
If you install some system requirements (e.g. git, nodejs, your compiler, ...), you could specifiy to rebuild it every 30d, but the next pipeline that pulls your specific dependencies (npm, go packages etc) is refreshed every 12h.
The container state that is created at this point is than cached for the maximum specified time, maybe by simply tagging the docker image, just like Docker builds are cached when the context and the Dockerfile doesn't change.
The big question is how the clone is supposed to work there. Probably by defining prepare steps and clone the project afterwards. Or clone into a mount at the beginning and keep it even with different containers.
Alternative
The
Additional context
No response
Validations
Beta Was this translation helpful? Give feedback.
All reactions