{"id":15062520,"url":"https://github.com/isac322/buildkit-state","last_synced_at":"2025-04-10T14:21:46.222Z","repository":{"id":81270176,"uuid":"586571329","full_name":"isac322/buildkit-state","owner":"isac322","description":"Github action for caching buildkit state","archived":false,"fork":false,"pushed_at":"2024-06-10T02:37:02.000Z","size":3089,"stargazers_count":5,"open_issues_count":20,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T13:03:57.952Z","etag":null,"topics":["actions","buildkit","buildkit-state","cache"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/isac322.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-08T15:57:54.000Z","updated_at":"2025-02-01T18:59:40.000Z","dependencies_parsed_at":"2023-10-23T14:51:16.088Z","dependency_job_id":"7b353ea3-b0cf-4ba5-87cd-31988ad5f290","html_url":"https://github.com/isac322/buildkit-state","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isac322%2Fbuildkit-state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isac322%2Fbuildkit-state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isac322%2Fbuildkit-state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isac322%2Fbuildkit-state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isac322","download_url":"https://codeload.github.com/isac322/buildkit-state/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248233935,"owners_count":21069493,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","buildkit","buildkit-state","cache"],"created_at":"2024-09-24T23:41:56.406Z","updated_at":"2025-04-10T14:21:46.207Z","avatar_url":"https://github.com/isac322.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# buildkit-state\n\nDramatically speeds up the build of Dockerfiles that require compiling or building dependencies.  \nInspired by [dashevo/gh-action-cache-buildkit-state](https://github.com/dashevo/gh-action-cache-buildkit-state).\n\n- Support Github actions cache or S3 as remote cache storage\n- Simple setup\n- Works well with [`docker/setup-buildx-action`](https://github.com/docker/setup-buildx-action)\n  and [`docker/build-push-action`](https://github.com/docker/build-push-action)\n- Customizable - Compression level \u0026 cache type \u0026\u0026 caching policy\n\n## Goal\n\nThe [BuildKit cache (e.g. `--mount=type=cache,target=/some/path`)](https://docs.docker.com/engine/reference/builder/#run---mounttypecache)\nis different from the layer cache\nand [it can make image build very fast](https://vsupalov.com/buildkit-cache-mount-dockerfile/).\nBut unlike layer cache, [`docker/build-push-action`](https://github.com/docker/build-push-action)'\ns `cache-to`\u0026`cache-from` does not includes buildkit cache.  \nThis action can restore/save BuildKit state on workflow to speed up CI/CD.\n\n## Benchmark\n\nSee [example projects](example) for reproducible code.\n\n```mermaid\ngantt\n    title Docker Build time\n    dateFormat  X\n    axisFormat %s\n\n    section First build\n        Vanilla (6m37s): active, 0, 337\n        With BuildKit Caching (6m41s): 0, 341\n    section Second build\n        Vanilla (6m37s): active, 0, 337\n        With BuildKit Caching (10s): 0, 10\n    section Add a dep\n        Vanilla (6m39s): active, 0, 339\n        With BuildKit Caching (10s): 0, 10\n```\n\n## Usage\n\nSee [example projects](example) and [example workflow](.github/workflows/benchmark.yaml) for more detailed usages.\n\n### Example Dockerfile\n\n```dockerfile\nFROM python:3.11\n\nRUN --mount=type=cache,target=/root/.cache/pip \\\n    pip install pandas uvicorn[standard] fastapi\n```\n\n### Caching every commit\n\n```yaml\non:\n  pull_request:\n  workflow_dispatch:\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Set up Docker Buildx\n        id: buildx\n        uses: docker/setup-buildx-action@v2\n\n      - name: Restore BuildKit state\n        uses: isac322/buildkit-state@v2\n        with:\n          buildx-name: ${{ steps.buildx.outputs.name }}\n\n      - name: Build\n        uses: docker/build-push-action@v4\n        with:\n          push: false\n```\n\n## Inputs\n\n| Name                 | Type            | Required | Default value                                       | Description                                                                                                |\n|----------------------|-----------------|:--------:|-----------------------------------------------------|------------------------------------------------------------------------------------------------------------|\n| `buildx-name`        | String          |    ⭕     |                                                     | Name of buildx. Fill name output `of docker/setup-buildx-action` actions.                                  |\n| `cache-key`          | String          |    ⭕     | `${{ runner.os }}-buildkit_state-${{ github.sha }}` | Unique id of cache. When loading, it is used for retrieval, and when saving, it is allocated to the cache. |\n| `cache-restore-keys` | List of string  |    ⭕     | `${{ runner.os }}-buildkit_state-`                  | Keys to be used if the search with `cache-key` fails on load.                                              |\n| `target-types`       | List of enum ¹  |    ⭕     | `exec.cachemount` and `frontend`                    | Choose which type of BuildKit state to save. You can use the default value in most cases.                  |\n| `rewrite-cache`      | Boolean         |          | `false`                                             | Whether to overwrite when the same cache key already exists.                                               |\n| `save-on-failure`    | Boolean         |          | `false`                                             | Whether to save cache even if job fails.                                                                   |\n| `resume-builder`     | Boolean         |          | `true`                                              | Resume buildx builder after successfully load cache and print disk usage.                                  |\n| `compression-level`  | Integer (1~22)  |          | `3`                                                 | Zstd compression level (from 1 to 22)                                                                      |\n| `window-size`        | Integer (10~31) |          | `27`                                                | Zstd window size (from 10 to 31)                                                                           |\n\n\u003e Note\n\u003e - ¹ Currently `regular`, `source.local`, `exec.cachemount`, `frontend`, `internal` are\n    supported ([Source](https://pkg.go.dev/github.com/moby/buildkit/client#UsageRecordType))\n\n## Output\n\n| Name                 | Type   | Description             |\n|----------------------|--------|-------------------------|\n| `restored-cache-key` | String | Cache key restored from |\n\n## Requirements\n\nIn most case, you **do not need to consider** these requirements.  \nGithub hosted runner fulfill all these requirements,\nbut self hosted BuildKit daemon may not work.\n\n- Only supports [BuildKit docker-container driver](https://docs.docker.com/build/drivers/) (which is default driver\n  of `docker/setup-buildx-action`)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisac322%2Fbuildkit-state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisac322%2Fbuildkit-state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisac322%2Fbuildkit-state/lists"}