feat(maintenance): add Docker build-cache prune action
Add an admin-only POST /api/docker/prune-build-cache endpoint plus a Settings > Maintenance danger-zone button to reclaim disk used by the Docker build cache (image + static-site builds), which previously grew unbounded with no UI lever. Prunes unused-only (all=false) so a warm cache is preserved for apps redeploying soon. Mirrors the existing prune-images vertical slice; full en/ru i18n parity.
This commit is contained in:
@@ -108,3 +108,29 @@ func (c *Client) GetSystemStats(ctx context.Context) (SystemStats, error) {
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
// BuildCachePruneResult reports the outcome of a build-cache prune.
|
||||
type BuildCachePruneResult struct {
|
||||
CachesDeleted int `json:"caches_deleted"` // number of cache records removed
|
||||
SpaceReclaimed int64 `json:"space_reclaimed"` // bytes reclaimed
|
||||
}
|
||||
|
||||
// PruneBuildCache deletes unused Docker build-cache records and returns the
|
||||
// number of records removed and bytes reclaimed. Docker's build-cache API is
|
||||
// prune-by-filter only — there is no surgical per-record eviction — so this
|
||||
// is the daemon-wide "prune unused" operation.
|
||||
//
|
||||
// When all is false (the default), only build cache not currently in use is
|
||||
// removed, so an app's next rebuild still hits its warm cache. When all is
|
||||
// true, every build-cache record is removed regardless of use, forcing a cold
|
||||
// rebuild for every app.
|
||||
func (c *Client) PruneBuildCache(ctx context.Context, all bool) (BuildCachePruneResult, error) {
|
||||
res, err := c.api.BuildCachePrune(ctx, client.BuildCachePruneOptions{All: all})
|
||||
if err != nil {
|
||||
return BuildCachePruneResult{}, fmt.Errorf("prune build cache: %w", err)
|
||||
}
|
||||
return BuildCachePruneResult{
|
||||
CachesDeleted: len(res.Report.CachesDeleted),
|
||||
SpaceReclaimed: int64(res.Report.SpaceReclaimed),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user