Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: add build cache checkbox to prune dialog
Kyle Mendell5db08fc2ea41
diff --git a/backend/internal/api/system_handler.go b/backend/internal/api/system_handler.goindex 6bde34910..8bd35b750 100644--- a/backend/internal/api/system_handler.go+++ b/backend/internal/api/system_handler.go@@ -183,6 +183,7 @@ func (h *SystemHandler) PruneAll(c *gin.Context) {slog.Bool("images", req.Images),slog.Bool("volumes", req.Volumes),slog.Bool("networks", req.Networks),+ slog.Bool("build_cache", req.BuildCache),slog.Bool("dangling", req.Dangling))result, err := h.systemService.PruneAll(ctx, req)@@ -326,12 +327,10 @@ func (h *SystemHandler) GetStatsWS(c *gin.Context) {Hostname: hostname,}- // write as JSON text message_ = conn.SetWriteDeadline(time.Now().Add(10 * time.Second))return conn.WriteJSON(stats)}- // initial sendif err := sendStats(); err != nil {slog.Debug("failed to send initial system stats websocket", "err", err)returndiff --git a/backend/internal/dto/prune_dto.go b/backend/internal/dto/prune_dto.goindex ace59b5fc..8e915510d 100644--- a/backend/internal/dto/prune_dto.go+++ b/backend/internal/dto/prune_dto.go@@ -5,6 +5,7 @@ type PruneSystemDto struct {Images bool `json:"images"`Volumes bool `json:"volumes"`Networks bool `json:"networks"`+ BuildCache bool `json:"buildCache"`Dangling bool `json:"dangling"`}diff --git a/backend/internal/services/system_service.go b/backend/internal/services/system_service.goindex ceb9a1f63..c4531d9d2 100644--- a/backend/internal/services/system_service.go+++ b/backend/internal/services/system_service.go@@ -52,47 +52,38 @@ func (s *SystemService) PruneAll(ctx context.Context, req dto.PruneSystemDto) (*slog.Bool("images", req.Images),slog.Bool("volumes", req.Volumes),slog.Bool("networks", req.Networks),+ slog.Bool("build_cache", req.BuildCache),slog.Bool("dangling", req.Dangling))- result := &dto.PruneAllResult{- Success: true,- }+ result := &dto.PruneAllResult{Success: true}if req.Containers {- slog.DebugContext(ctx, "Processing container pruning")if err := s.pruneContainers(ctx, result); err != nil {result.Errors = append(result.Errors, fmt.Sprintf("Container pruning failed: %v", err))result.Success = false}}- if req.Images {- danglingOnly, settingsErr := s.getDanglingModeFromSettings(ctx)- if settingsErr != nil {- danglingOnly = req.Dangling- result.Errors = append(result.Errors, fmt.Sprintf("Warning: Could not get prune mode from settings, using request parameter: %v", settingsErr))- slog.WarnContext(ctx, "Could not get prune mode from settings, using request parameter",- slog.String("error", settingsErr.Error()),- slog.Bool("fallback_dangling", req.Dangling))- }-- slog.DebugContext(ctx, "Processing image pruning",- slog.Bool("settings_dangling_mode", danglingOnly),- slog.Bool("request_dangling", req.Dangling))+ danglingOnly, err := s.getDanglingModeFromSettings(ctx)+ if err != nil {+ danglingOnly = req.Dangling+ }+ slog.DebugContext(ctx, "Resolved image prune mode", slog.Bool("dangling_only", danglingOnly))+ if req.Images {if err := s.pruneImages(ctx, danglingOnly, result); err != nil {result.Errors = append(result.Errors, fmt.Sprintf("Image pruning failed: %v", err))result.Success = false}+ }- slog.DebugContext(ctx, "Processing build cache pruning as part of image pruning")+ if req.BuildCache {if buildCacheErr := s.pruneBuildCache(ctx, result, !danglingOnly); buildCacheErr != nil {slog.WarnContext(ctx, "Build cache pruning encountered an error", slog.String("error", buildCacheErr.Error()))}}if req.Volumes {- slog.DebugContext(ctx, "Processing volume pruning")if err := s.pruneVolumes(ctx, result); err != nil {result.Errors = append(result.Errors, fmt.Sprintf("Volume pruning failed: %v", err))result.Success = false@@ -100,7 +91,6 @@ func (s *SystemService) PruneAll(ctx context.Context, req dto.PruneSystemDto) (*}if req.Networks {- slog.DebugContext(ctx, "Processing network pruning")if err := s.pruneNetworks(ctx, result); err != nil {result.Errors = append(result.Errors, fmt.Sprintf("Network pruning failed: %v", err))result.Success = false@@ -315,13 +305,8 @@ func (s *SystemService) pruneBuildCache(ctx context.Context, result *dto.PruneAl}func (s *SystemService) pruneVolumes(ctx context.Context, result *dto.PruneAllResult) error {+ // Always prune only unused volumes here (safe default)allVolumes := false- if s.settingsService != nil {- danglingOnly, _ := s.getDanglingModeFromSettings(ctx)- allVolumes = !danglingOnly- }- slog.DebugContext(ctx, "Processing volume pruning", slog.Bool("all", allVolumes))-report, err := s.volumeService.PruneVolumesWithOptions(ctx, allVolumes)if err != nil {return errdiff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 7a6c67383..ec4152301 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -1058,5 +1058,6 @@"polling_daily_description": "Check for new images every 1440 minutes","polling_weekly_description": "Check for new images every 10080 minutes","use_custom_polling_value": "Use a custom polling value between 5-10080 minutes",- "custom_polling_interval": "Custom Polling Interval (minutes)"+ "custom_polling_interval": "Custom Polling Interval (minutes)",+ "build_cache": "Build Cache"}diff --git a/frontend/src/lib/components/dialogs/prune-confirmation-dialog.svelte b/frontend/src/lib/components/dialogs/prune-confirmation-dialog.svelteindex 8b64ec0d2..be8bd4cb0 100644--- a/frontend/src/lib/components/dialogs/prune-confirmation-dialog.svelte+++ b/frontend/src/lib/components/dialogs/prune-confirmation-dialog.svelte@@ -9,7 +9,7 @@import * as Alert from '$lib/components/ui/alert/index.js';import { m } from '$lib/paraglide/messages';- type PruneType = 'containers' | 'images' | 'networks' | 'volumes';+ type PruneType = 'containers' | 'images' | 'networks' | 'volumes' | 'buildCache';interface Props {open?: boolean;@@ -31,6 +31,7 @@let pruneImages = $state(true);let pruneNetworks = $state(true);let pruneVolumes = $state(false);+ let pruneBuildCache = $state(false);const selectedTypes = $derived.by(() => {const types: PruneType[] = [];@@ -38,6 +39,7 @@if (pruneImages) types.push('images');if (pruneNetworks) types.push('networks');if (pruneVolumes) types.push('volumes');+ if (pruneBuildCache) types.push('buildCache');return types;});@@ -73,9 +75,11 @@<Labelfor="prune-containers"class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"- >{m.prune_stopped_containers()}</Label>+ {m.prune_stopped_containers()}+ </Label></div>+<div class="flex items-center space-x-3"><Checkbox.Root id="prune-images" bind:checked={pruneImages} disabled={isPruning} /><Label@@ -85,14 +89,28 @@{m.prune_unused_images()} ({imagePruneMode === 'dangling' ? m.prune_images_mode_dangling() : m.prune_images_mode_all()})</Label></div>++ <!-- Build cache -->+ <div class="flex items-center space-x-3">+ <Checkbox.Root id="prune-build-cache" bind:checked={pruneBuildCache} disabled={isPruning} />+ <Label+ for="prune-build-cache"+ class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"+ >+ {m.build_cache()}+ </Label>+ </div>+<div class="flex items-center space-x-3"><Checkbox.Root id="prune-networks" bind:checked={pruneNetworks} disabled={isPruning} /><Labelfor="prune-networks"class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"- >{m.prune_unused_networks()}</Label>+ {m.prune_unused_networks()}+ </Label></div>+<div class="flex items-start space-x-3"><Checkbox.Root id="prune-volumes" bind:checked={pruneVolumes} disabled={isPruning} class="mt-1" /><div class="grid gap-1.5 leading-none">@@ -113,9 +131,9 @@</div><Dialog.Footer>- <Button class="arcane-button-cancel" variant="outline" onclick={handleCancel} disabled={isPruning}- >{m.common_cancel()}</Button- >+ <Button class="arcane-button-cancel" variant="outline" onclick={handleCancel} disabled={isPruning}>+ {m.common_cancel()}+ </Button><Buttonclass="arcane-button-remove"variant="destructive"diff --git a/frontend/src/lib/services/api/system-api-service.ts b/frontend/src/lib/services/api/system-api-service.tsindex 1bc30780d..0cb6b4119 100644--- a/frontend/src/lib/services/api/system-api-service.ts+++ b/frontend/src/lib/services/api/system-api-service.ts@@ -7,6 +7,7 @@ export default class SystemAPIService extends BaseAPIService {images?: boolean;volumes?: boolean;networks?: boolean;+ buildCache?: boolean;dangling?: boolean;until?: string;}) {diff --git a/frontend/src/routes/dashboard/+page.svelte b/frontend/src/routes/dashboard/+page.svelteindex eaf3c2cdc..1a05b0de8 100644--- a/frontend/src/routes/dashboard/+page.svelte+++ b/frontend/src/routes/dashboard/+page.svelte@@ -47,7 +47,7 @@isPruneDialogOpen: false});- type PruneType = 'containers' | 'images' | 'networks' | 'volumes';+ type PruneType = 'containers' | 'images' | 'networks' | 'volumes' | 'buildCache';let isLoading = $state({starting: false,@@ -268,10 +268,18 @@images: selectedTypes.includes('images'),volumes: selectedTypes.includes('volumes'),networks: selectedTypes.includes('networks'),+ buildCache: selectedTypes.includes('buildCache'),dangling: dashboardStates.settings?.dockerPruneMode === 'dangling'};- const typesString = selectedTypes.map((type) => capitalizeFirstLetter(type)).join(', ');+ const typeLabels: Record<PruneType, string> = {+ containers: m.prune_stopped_containers(),+ images: m.prune_unused_images(),+ networks: m.prune_unused_networks(),+ volumes: m.prune_unused_volumes(),+ buildCache: 'Build cache'+ };+ const typesString = selectedTypes.map((t) => typeLabels[t]).join(', ');handleApiResultWithCallbacks({result: await tryCatch(systemAPI.pruneAll(pruneOptions)),