Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ This action follows semantic versioning and supports multiple referencing patter

## Inputs

| Name | Description | Required | Default |
| ------------------ | ------------------------------------------------------------------ | -------- | -------------- |
| `buildx-version` | Buildx version (e.g., v0.23.0, latest) | No | `v0.23.0` |
| `buildkit-version` | BuildKit version to install (e.g., v0.16.0, v0.18.0) | No | System default |
| `platforms` | List of target platforms for build (e.g., linux/amd64,linux/arm64) | No | |
| `nofallback` | If true, fail the action if Blacksmith builder setup fails | No | `false` |
| `github-token` | GitHub token for GitHub API access | No | |
| Name | Description | Required | Default |
| ---------------------- | ------------------------------------------------------------------------------------------------------------- | -------- | -------------- |
| `buildx-version` | Buildx version (e.g., v0.23.0, latest) | No | `v0.23.0` |
| `buildkit-version` | BuildKit version to install (e.g., v0.16.0, v0.18.0) | No | System default |
| `platforms` | List of target platforms for build (e.g., linux/amd64,linux/arm64) | No | |
| `nofallback` | If true, fail the action if Blacksmith builder setup fails | No | `false` |
| `github-token` | GitHub token for GitHub API access | No | |
| `skip-integrity-check` | If true, skip the bbolt database integrity check | No | `false` |
| `driver-opts` | List of additional driver-specific options (e.g., env.VARIABLE=value) | No | |
| `max-parallelism` | Maximum number of concurrent BuildKit RUN steps. Defaults to the number of vCPUs on the runner | No | |
| `max-cache-size` | Amount of build cache to retain after pruning, in MB (e.g., 409600 for 400GB). If not set, pruning is skipped | No | |

## Example Workflows

Expand Down Expand Up @@ -84,6 +88,20 @@ This action follows semantic versioning and supports multiple referencing patter
tags: user/app2:latest
```

### Cache management

Use `max-cache-size` to automatically prune the BuildKit cache after each build, retaining the specified amount in MB. This prevents the cache from growing unbounded while keeping the most recent layers available. The layers will be trimmed based off of the last accessed timestamp stored in the cache manager.

```yaml
- uses: useblacksmith/setup-docker-builder@v1
with:
max-cache-size: "409600" # retain up to 400 GB of build cache
- uses: useblacksmith/build-push-action@v2
with:
push: true
tags: user/app:latest
```

### Custom Docker commands

```yaml
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ inputs:
max-parallelism:
description: "Maximum number of concurrent BuildKit RUN steps. Defaults to the number of vCPUs on the runner."
required: false
cache-keep-storage:
max-cache-size:
description: "Amount of build cache to retain after pruning, in MB (e.g., 409600 for 400GB). If not set, pruning is skipped."
required: false
runs:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,14 +563,14 @@ async function maybeShutdownBuildkitd(): Promise<void> {
await logBuildCacheContents();

try {
const keepStorageInput = core.getInput("cache-keep-storage");
const keepStorageInput = core.getInput("max-cache-size");
if (!keepStorageInput) {
core.info("Skipping BuildKit cache pruning (cache-keep-storage not set)");
core.info("Skipping BuildKit cache pruning (max-cache-size not set)");
} else {
const keepStorageMB = parseInt(keepStorageInput, 10);
if (isNaN(keepStorageMB) || keepStorageMB < 0) {
core.warning(
`Invalid cache-keep-storage value '${keepStorageInput}', skipping pruning. Must be a non-negative integer (MB).`,
`Invalid max-cache-size value '${keepStorageInput}', skipping pruning. Must be a non-negative integer (MB).`,
);
} else {
core.info(`Pruning BuildKit cache (keep at least ${keepStorageMB} MB)`);
Expand Down
Loading