GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Cache BuildKit state volume · Issue #122 · docker/setup-buildx-action

Cache BuildKit state volume #122

New issue
Copy link
New issue
Copy link
Open
Open
Cache BuildKit state volume#122
Copy link
Assignees
crazy-max
Labels
kind/enhancement

Description

@crazy-max
crazy-max
opened on Jan 17, 2022
Issue body actions

follow-up docker/build-push-action#482

Since docker/buildx#672 BuildKit state is saved in a named volume. We should be able to cache it and mount it back. This would require the possiblity to name the builder instead of a generated one.

Reacted by Paul Sanchez, Travis Cline, Jeff Bzdawka, Devminded, R Gibim, Charles Tison, Max Countryman, Miguel A. Alvarado V., Bruno Palermo, Artur Sinila and 22 more

Activity

  1. crazy-max
    added
    kind/enhancement
    on Jan 17, 2022
  2. basicdays commented on Jan 18, 2022

    @basicdays
    basicdays
    on Jan 18, 2022
    More actions

    This would be insanely awesome. Would this also cover the situation of not having to set cache-from and cache-to? My understanding is that image layer caching by default is kept in buildkit?

  3. tmc commented on Jan 19, 2022

    @tmc
    tmc
    on Jan 19, 2022
    More actions

    This could be huge for speeding up larger or more complicated builds.

  4. crazy-max commented on Jan 19, 2022

    @crazy-max
    crazy-max
    on Jan 19, 2022
    MemberAuthor
    More actions

    This would be insanely awesome. Would this also cover the situation of not having to set cache-from and cache-to? My understanding is that image layer caching by default is kept in buildkit?

    Yes cache exporter would not be required in this case. Note that this solution would only work with GitHub Actions and a defined builder as this is a the local state.

    Reacted by Paul Sanchez and berlin4apk
  5. Richard87 commented on Jan 19, 2022

    @Richard87
    Richard87
    on Jan 19, 2022
    More actions

    Imagine of much compute resources would be saved if everyone building docker images on github saved 30sec each time 🤯

  6. devminded commented on Jan 21, 2022

    @devminded
    devminded
    on Jan 21, 2022
    More actions

    @Richard87 in this article they saved way more than 30 seconds.
    https://evilmartians.com/chronicles/build-images-on-github-actions-with-docker-layer-caching

  7. Richard87 commented on Jan 21, 2022

    @Richard87
    Richard87
    on Jan 21, 2022
    More actions

    Thanks @devminded ! I remember I already do thos tings, uts jjust when I update a node dependency or PHP dependencies that everything takes forever 🤔

  8. Drowze commented on Feb 17, 2022

    @Drowze
    Drowze
    on Feb 17, 2022
    More actions

    This is very desired feature 😄

    For our ruby applications, our Dockerfile look sorta like:

    FROM alpine-ruby:latest
    RUN mkdir /app
    COPY Gemfile Gemfile.lock .ruby-version /app
    RUN bundle install
    
    COPY . /app

    ...so any change to our installed dependencies (described on Gemfile and Gemfile.lock) invalidates the layer that actually install the dependencies (bundle install), meaning we fetch and install all dependencies if a single dependency is changed.

    I'm sure this is a very common scenario and, if it was possible to cache the dependencies directory in a docker volume and reuse that docker volume to build new images in between triggered pipelines, I'm sure the impact would be huge!

    Very much looking forward to this 👍

  9. crazy-max commented on Feb 17, 2022

    @crazy-max
    crazy-max
    on Feb 17, 2022
    MemberAuthor
    More actions

    @Drowze

    if it was possible to cache the dependencies directory

    You can already cache dependencies using the RUN --mount=type=cache mount. See this example: https://github.com/portapps/portapps.github.io/blob/cde4dd6de0a2876f0311ae321f25f454cf417076/dev.Dockerfile#L7-L13

  10. Drowze commented on Feb 17, 2022

    @Drowze
    Drowze
    on Feb 17, 2022
    More actions

    @crazy-max

    You can already cache dependencies using the RUN --mount=type=cache mount. See this example: https://github.com/portapps/portapps.github.io/blob/cde4dd6de0a2876f0311ae321f25f454cf417076/dev.Dockerfile#L7-L13

    So using RUN --mount=type=cache will cache that mount in between builds using gha caching type? Even on GitHub managed runners (not self-hosted)? 🤔
    I'll give it a try. Thanks for pointing me that @crazy-max 😄

  11. crazy-max commented on Feb 17, 2022

    @crazy-max
    crazy-max
    on Feb 17, 2022
    MemberAuthor
    More actions

    So using RUN --mount=type=cache will cache that mount in between builds using gha caching type? Even on GitHub managed runners (not self-hosted)? 🤔

    No it will not export this cache (cache-to) but it will be cached to the buildkit state (volume). You can try it locally.

  12. wille commented on Dec 12, 2022

    @wille
    wille
    on Dec 12, 2022
    More actions

    setup-buildx-action is unusable in larger builds because of the lack for buildkit state caching support

  13. ibalajiarun commented on Apr 19, 2023

    @ibalajiarun
    ibalajiarun
    on Apr 19, 2023
    More actions

    I have this PR out to address this: #211

  14. crazy-max commented on Apr 19, 2023

    @crazy-max
    crazy-max
    on Apr 19, 2023
    MemberAuthor
    More actions

    I have this PR out to address this: #211

    Keeping BuildKit state will not work on public runners, hence #138 to try to address this.

  15. ibalajiarun commented on Apr 19, 2023

    @ibalajiarun
    ibalajiarun
    on Apr 19, 2023
    More actions

    Yes, thats is true. Thanks for clarification. #211 will only work with persistent self-hosted runners.

  16. thompson-shaun
    assigned
    crazy-max
    on May 19, 2025
  17. crohr commented on Jul 10, 2026

    @crohr
    crohr
    on Jul 10, 2026
    More actions

    @crazy-max hello, what can we do to make this feature happen? would go hand in hand with #427.

    Keeping BuildKit state will not work on public runners

    A lot of runner providers now offer snapshotting / sticky disks, etc. Having a way to name the builder would be really nice so that we can do some magic around it (e.g. pre-create / re-hydrate the state volume before buildkit starts, stuff like that).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @crazy-max
    crazy-max

Labels

kind/enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.