Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore using cache for docker build #452

Open
danielhollas opened this issue May 9, 2024 · 4 comments
Open

Explore using cache for docker build #452

danielhollas opened this issue May 9, 2024 · 4 comments

Comments

@danielhollas
Copy link
Contributor

           set: |
               *.platform=linux/amd64
               *.output=type=registry,push-by-digest=true,name-canonical=true
               *.cache-from=type=local,src=/tmp/.buildx-cache
               *.cache-to=type=local,mode=max,dest=/tmp/.buildx-cache-new
           files: |
               docker-bake.hcl
               build.json

     # Temp fix for issue of fast size grow in local caching:
     # https://github.com/docker/build-push-action/issues/252
     # https://github.com/moby/buildkit/issues/1896
     - name: Move cache
       run: |
         rm -rf /tmp/.buildx-cache
         mv /tmp/.buildx-cache-new /tmp/.buildx-cache

Could you give it a try on caching? This may further speed the build?

Originally posted by @unkcpz in #439 (comment)

@danielhollas
Copy link
Contributor Author

danielhollas commented May 9, 2024

Looks like a simpler solution is now available that uses GHA cache directly

https://github.com/restatedev/restate/pull/492/files

See also documentation here:
https://docs.docker.com/build/ci/github-actions/cache/

@danielhollas
Copy link
Contributor Author

Might not be so easy in the end:
docker/bake-action#87

@unkcpz
Copy link
Member

unkcpz commented May 9, 2024

Yep. I did a try in https://github.com/pspgen/build-machine/blob/478dbcebdc521d916f2c72f0500f67898d2a9f13/.github/workflows/ci.yml#L55-L73 ;) which borrow most of the idea from your PR. The build of my image takes 10 mins, using cache safe me half day at least 😄

@danielhollas
Copy link
Contributor Author

danielhollas commented May 23, 2024

So just to followup here, the cache works only partially. I suspect there is some cache-trashing since we're building multiple images and multiple platforms. So the cache wins us a bit, but could be much better. Perhaps worth looking into more in the future.

This issue is probably relevant docker/bake-action#87 (note the last comment by Simon)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants