As someone who spent way too much time chasing this rabbit, the real answer is Just Don't. GitHub Actions is a CI system that makes it easy to get started with simple CI needs but runs into hard problems as soon as you have more advanced needs. Docker caching is one of those advanced needs. If you have non-trivial Docker builds then you simply need on-disk local caching, period. Either use Depot or switch to self-hos…
Cache is King: A guide for Docker layer caching in GitHub Actions
21–30 of 111 posts
Re: Cache is King: A guide for Docker layer caching in GitHub Actions
#22As someone who spent way too much time chasing this rabbit, the real answer is Just Don't. GitHub Actions is a CI system that makes it easy to get started with simple CI needs but runs into hard problems as soon as you have more advanced needs. Docker caching is one of those advanced needs. If you have non-trivial Docker builds then you simply need on-disk local caching, period. Either use Depot or switch to self-hos…
Re: Cache is King: A guide for Docker layer caching in GitHub Actions
#23I weep for this period of time where we don't have sticky disks readily available for builds. Uploading the layer cache each time is such a coarse and time-consuming way to cache things. Maybe building from scratch all the time is a good correctness decision? Maybe stale values in disks is a tricky enough issue to want to avoid entirely? If you keep a stack of disks around and grab a free one when the job starts you'…
I remember working on a project where the first clean build would always fail, and only incremental builds could succeed. I was a junior at the time, so this was 15-20 years ago. I remember spending some time trying to get it to succeed from a clean build and my lead pulling me aside: he said it was an easy fix, but if we fixed it, the ops guys would insist on building from scratch for every build. So please, stop.
Personally, unless you have an exotic build env, it’s usually faster and easier to simply build in the runner. If you need a docker image at the end, build a dockerfile that simply copies the artifacts from disk.
Re: Cache is King: A guide for Docker layer caching in GitHub Actions
#24Earlier quoted context omitted.
how do you ensure isolation between runs on a self hosted runner that way?
Selh-hosted runners can be ephemeral too. With such either mount the cache as a disk or bake docker layers/images into the runner image.
Re: Cache is King: A guide for Docker layer caching in GitHub Actions
#25Earlier quoted context omitted.
Selh-hosted runners can be ephemeral too. With such either mount the cache as a disk or bake docker layers/images into the runner image.
This requires a lot of work from a dev inf team, though. Not as straightforward for an average team.
Re: Cache is King: A guide for Docker layer caching in GitHub Actions
#26Earlier quoted context omitted.
What kind of isolation do you need? We are building our own code so I don't see the need for isolation beyond a clear directory.
Shared runner infrastructure in a big company. It's pretty common to treat these situations as multi-tenant low trust environments.
Re: Cache is King: A guide for Docker layer caching in GitHub Actions
#27(blacksmith co-founder here) it's unfortunate the amount of expertise / tinkering required to get "incrementalism" in docker builds in github actions. we're hoping to solve this with some of the stuff we have in the pipeline in the near future.
Re: Cache is King: A guide for Docker layer caching in GitHub Actions
#28Earlier quoted context omitted.
Selh-hosted runners can be ephemeral too. With such either mount the cache as a disk or bake docker layers/images into the runner image.
This requires a lot of work from a dev inf team, though. Not as straightforward for an average team.
I haven't used it yet but these two features make it the clear favourite for me in alternate github action runners
Re: Cache is King: A guide for Docker layer caching in GitHub Actions
#29(blacksmith co-founder here) it's unfortunate the amount of expertise / tinkering required to get "incrementalism" in docker builds in github actions. we're hoping to solve this with some of the stuff we have in the pipeline in the near future.
The fact that GitHub don't provide a better solution here has to be actually costing them money with the network usage and extra agent time consumed. Right?
Re: Cache is King: A guide for Docker layer caching in GitHub Actions
#30They rethink Dockerfiles with really good caching support.