Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: full control over prune options (#2372)
Kyle Mendell80eebf70f908
diff --git a/backend/internal/configschema/schema.go b/backend/internal/configschema/schema.goindex aca671638..bdd036d96 100644--- a/backend/internal/configschema/schema.go+++ b/backend/internal/configschema/schema.go@@ -102,20 +102,61 @@ var overrideDocRules = map[string]overrideDocRule{requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",},"scheduledPruneContainers": {- requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ deprecated: true,+ requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ note: "Legacy boolean prune flag retained for migration compatibility. Prefer PRUNE_CONTAINER_MODE.",},"scheduledPruneImages": {- requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ deprecated: true,+ requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ note: "Legacy boolean prune flag retained for migration compatibility. Prefer PRUNE_IMAGE_MODE.",},"scheduledPruneVolumes": {- requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ deprecated: true,+ requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ note: "Legacy boolean prune flag retained for migration compatibility. Prefer PRUNE_VOLUME_MODE.",},"scheduledPruneNetworks": {- requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ deprecated: true,+ requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ note: "Legacy boolean prune flag retained for migration compatibility. Prefer PRUNE_NETWORK_MODE.",},"scheduledPruneBuildCache": {+ deprecated: true,+ requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ note: "Legacy boolean prune flag retained for migration compatibility. Prefer PRUNE_BUILD_CACHE_MODE.",+ },+ "pruneContainerMode": {+ requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ },+ "pruneContainerUntil": {+ requires: "SCHEDULED_PRUNE_ENABLED=true and PRUNE_CONTAINER_MODE=olderThan to have effect at runtime.",+ },+ "pruneImageMode": {+ requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ },+ "pruneImageUntil": {+ requires: "SCHEDULED_PRUNE_ENABLED=true and PRUNE_IMAGE_MODE=olderThan to have effect at runtime.",+ },+ "pruneVolumeMode": {+ requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ },+ "pruneNetworkMode": {requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",},+ "pruneNetworkUntil": {+ requires: "SCHEDULED_PRUNE_ENABLED=true and PRUNE_NETWORK_MODE=olderThan to have effect at runtime.",+ },+ "pruneBuildCacheMode": {+ requires: "SCHEDULED_PRUNE_ENABLED=true to have effect at runtime.",+ },+ "pruneBuildCacheUntil": {+ requires: "SCHEDULED_PRUNE_ENABLED=true and PRUNE_BUILD_CACHE_MODE=olderThan to have effect at runtime.",+ },+ "dockerPruneMode": {+ deprecated: true,+ note: "Legacy prune mode retained for migration compatibility. Prefer the granular scheduled prune mode settings.",+ },"vulnerabilityScanInterval": {requires: "VULNERABILITY_SCAN_ENABLED=true to have effect at runtime.",},diff --git a/backend/internal/configschema/schema_test.go b/backend/internal/configschema/schema_test.goindex 8214c409b..5986e9608 100644--- a/backend/internal/configschema/schema_test.go+++ b/backend/internal/configschema/schema_test.go@@ -271,7 +271,6 @@ var expectedSettingOverrideKeys = []string{"dockerApiTimeout","dockerHost","dockerImagePullTimeout",- "dockerPruneMode","enableGravatar","environmentHealthInterval","eventCleanupInterval",@@ -308,6 +307,15 @@ var expectedSettingOverrideKeys = []string{"pollingInterval","projectsDirectory","proxyRequestTimeout",+ "pruneBuildCacheMode",+ "pruneBuildCacheUntil",+ "pruneContainerMode",+ "pruneContainerUntil",+ "pruneImageMode",+ "pruneImageUntil",+ "pruneNetworkMode",+ "pruneNetworkUntil",+ "pruneVolumeMode","registryTimeout","scheduledPruneBuildCache","scheduledPruneContainers",diff --git a/backend/internal/huma/handlers/dashboard_test.go b/backend/internal/huma/handlers/dashboard_test.goindex 674f62c0c..20b8f3d41 100644--- a/backend/internal/huma/handlers/dashboard_test.go+++ b/backend/internal/huma/handlers/dashboard_test.go@@ -124,7 +124,7 @@ func TestDashboardHandlerGetDashboardReturnsSnapshot(t *testing.T) {require.Len(t, snapshot.Images.Data, 2)require.Equal(t, 1, snapshot.Containers.Counts.RunningContainers)require.Equal(t, 1, snapshot.Containers.Counts.StoppedContainers)- require.Equal(t, "dangling", snapshot.Settings.DockerPruneMode)+ require.Equal(t, dashboardtypes.SnapshotSettings{}, snapshot.Settings)require.ElementsMatch(t, []dashboardtypes.ActionItem{{Kind: dashboardtypes.ActionItemKindStoppedContainers, Count: 1, Severity: dashboardtypes.ActionItemSeverityWarning},{Kind: dashboardtypes.ActionItemKindImageUpdates, Count: 1, Severity: dashboardtypes.ActionItemSeverityWarning},diff --git a/backend/internal/huma/handlers/images.go b/backend/internal/huma/handlers/images.goindex e479ad8ba..e7b1d094a 100644--- a/backend/internal/huma/handlers/images.go+++ b/backend/internal/huma/handlers/images.go@@ -15,6 +15,7 @@ import ("github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/image"+ "github.com/getarcaneapp/arcane/types/system""gorm.io/gorm")@@ -114,6 +115,8 @@ type PruneImagesInput struct {EnvironmentID string `path:"id" doc:"Environment ID"`Dangling bool `query:"dangling" doc:"Only remove dangling images"`Body *struct {+ Mode *string `json:"mode,omitempty"`+ Until *string `json:"until,omitempty"`Dangling *bool `json:"dangling,omitempty"`Filters map[string][]string `json:"filters,omitempty"`}@@ -549,21 +552,13 @@ func (h *ImageHandler) PruneImages(ctx context.Context, input *PruneImagesInput)return nil, huma.Error500InternalServerError("service not available")}- dangling := input.Dangling- if input.Body != nil {- if input.Body.Dangling != nil {- dangling = *input.Body.Dangling- } else if vals, ok := input.Body.Filters["dangling"]; ok {- for _, v := range vals {- if v == "true" || v == "1" {- dangling = true- break- }- }- }- }+ mode := resolvePruneImageModeInternal(input)+ until := resolvePruneImageUntilInternal(input)- report, err := h.imageService.PruneImages(ctx, dangling)+ report, err := h.imageService.PruneImages(ctx, system.PruneImagesOptions{+ Mode: system.PruneImageMode(mode),+ Until: until,+ })if err != nil {return nil, huma.Error500InternalServerError((&common.ImagePruneError{Err: err}).Error())}@@ -578,6 +573,58 @@ func (h *ImageHandler) PruneImages(ctx context.Context, input *PruneImagesInput)}, nil}+func resolvePruneImageModeInternal(input *PruneImagesInput) string {+ mode := resolveLegacyPruneImageModeInternal(input.Dangling)+ if input.Body == nil {+ return mode+ }++ if input.Body.Mode != nil && strings.TrimSpace(*input.Body.Mode) != "" {+ return strings.TrimSpace(*input.Body.Mode)+ }++ if input.Body.Dangling != nil {+ return resolveLegacyPruneImageModeInternal(*input.Body.Dangling)+ }++ if vals, ok := input.Body.Filters["dangling"]; ok {+ for _, value := range vals {+ switch value {+ case "true", "1":+ return "dangling"+ case "false", "0":+ return "all"+ }+ }+ }++ return mode+}++func resolvePruneImageUntilInternal(input *PruneImagesInput) string {+ if input.Body == nil {+ return ""+ }++ if input.Body.Until != nil {+ return strings.TrimSpace(*input.Body.Until)+ }++ if vals, ok := input.Body.Filters["until"]; ok && len(vals) > 0 {+ return strings.TrimSpace(vals[0])+ }++ return ""+}++func resolveLegacyPruneImageModeInternal(dangling bool) string {+ if dangling {+ return "dangling"+ }++ return "all"+}+// GetImageUsageCounts returns counts of images by usage status.func (h *ImageHandler) GetImageUsageCounts(ctx context.Context, input *GetImageUsageCountsInput) (*GetImageUsageCountsOutput, error) {if h.dockerService == nil || h.imageService == nil {diff --git a/backend/internal/huma/handlers/system.go b/backend/internal/huma/handlers/system.goindex e638ec0e2..4672fba6a 100644--- a/backend/internal/huma/handlers/system.go+++ b/backend/internal/huma/handlers/system.go@@ -360,8 +360,7 @@ func (h *SystemHandler) PruneAll(ctx context.Context, input *PruneAllInput) (*Pr"images", input.Body.Images,"volumes", input.Body.Volumes,"networks", input.Body.Networks,- "build_cache", input.Body.BuildCache,- "dangling", input.Body.Dangling)+ "build_cache", input.Body.BuildCache)result, err := h.systemService.PruneAll(ctx, input.Body)if err != nil {diff --git a/backend/internal/models/settings.go b/backend/internal/models/settings.goindex ec2e9096a..58ff29780 100644--- a/backend/internal/models/settings.go+++ b/backend/internal/models/settings.go@@ -79,31 +79,46 @@ type Settings struct {PollingInterval SettingVariable `key:"pollingInterval" meta:"label=Polling Interval;type=cron;keywords=interval,frequency,schedule,time,minutes,period,delay;category=internal;description=How often to check for image updates (cron expression)"`EventCleanupInterval SettingVariable `key:"eventCleanupInterval" meta:"label=Event Cleanup Interval;type=cron;keywords=events,cleanup,retention,interval,frequency,schedule,history,logs,jobs;description=How often to delete old events (cron expression)"`AutoInjectEnv SettingVariable `key:"autoInjectEnv" meta:"label=Auto Inject Env Variables;type=boolean;keywords=auto,inject,env,environment,variables,interpolation;category=internal;description=Automatically inject project .env variables into all containers (default: false)"`- PruneMode SettingVariable `key:"dockerPruneMode" meta:"label=Docker Prune Action;type=select;keywords=prune,cleanup,clean,remove,delete,unused,dangling,space,disk;category=internal;description=Configure how unused Docker images are cleaned up"`- DefaultDeployPullPolicy SettingVariable `key:"defaultDeployPullPolicy" meta:"label=Default Deploy Pull Policy;type=select;keywords=deploy,pull,policy,compose,up,missing,always;category=internal;description=Default image pull policy when deploying projects"`- ScheduledPruneEnabled SettingVariable `key:"scheduledPruneEnabled" meta:"label=Scheduled Prune Enabled;type=boolean;keywords=prune,cleanup,maintenance,schedule,automatic;category=internal;description=Enable scheduled pruning of unused Docker resources"`- ScheduledPruneInterval SettingVariable `key:"scheduledPruneInterval" meta:"label=Scheduled Prune Interval;type=cron;keywords=prune,cleanup,interval,minutes,schedule;category=internal;description=How often to run scheduled prunes (cron expression)"`- GitopsSyncInterval SettingVariable `key:"gitopsSyncInterval" meta:"label=GitOps Sync Interval;type=cron;keywords=gitops,sync,interval,frequency,schedule,repository;category=internal;description=How often to run GitOps synchronization checks (cron expression)"`- ScheduledPruneContainers SettingVariable `key:"scheduledPruneContainers" meta:"label=Scheduled Prune Containers;type=boolean;keywords=prune,containers,cleanup,maintenance;category=internal;description=Remove stopped containers during scheduled prune"`- ScheduledPruneImages SettingVariable `key:"scheduledPruneImages" meta:"label=Scheduled Prune Images;type=boolean;keywords=prune,images,cleanup,maintenance;category=internal;description=Remove unused images during scheduled prune"`- ScheduledPruneVolumes SettingVariable `key:"scheduledPruneVolumes" meta:"label=Scheduled Prune Volumes;type=boolean;keywords=prune,volumes,cleanup,maintenance;category=internal;description=Remove unused volumes during scheduled prune"`- ScheduledPruneNetworks SettingVariable `key:"scheduledPruneNetworks" meta:"label=Scheduled Prune Networks;type=boolean;keywords=prune,networks,cleanup,maintenance;category=internal;description=Remove unused networks during scheduled prune"`- ScheduledPruneBuildCache SettingVariable `key:"scheduledPruneBuildCache" meta:"label=Scheduled Prune Build Cache;type=boolean;keywords=prune,build cache,cleanup,maintenance;category=internal;description=Remove Docker build cache during scheduled prune"`- AutoHealEnabled SettingVariable `key:"autoHealEnabled" meta:"label=Auto Heal;type=boolean;keywords=auto,heal,health,restart,unhealthy,recovery,container,healthcheck;category=internal;description=Automatically restart containers that become unhealthy"`- AutoHealInterval SettingVariable `key:"autoHealInterval" meta:"label=Auto Heal Interval;type=cron;keywords=auto,heal,interval,frequency,schedule,health,jobs;description=How often to check container health (cron expression)" catmeta:"id=jobschedule"`- AutoHealExcludedContainers SettingVariable `key:"autoHealExcludedContainers" meta:"label=Auto Heal Excluded Containers;type=text;keywords=auto,heal,exclude,containers,ignore,skip,health;category=internal;description=Comma-separated list of containers to exclude from auto-heal"`- AutoHealMaxRestarts SettingVariable `key:"autoHealMaxRestarts" meta:"label=Auto Heal Max Restarts;type=number;keywords=auto,heal,max,restarts,limit,loop,protection;category=internal;description=Maximum auto-heal restarts per container within the restart window (default: 5)"`- AutoHealRestartWindow SettingVariable `key:"autoHealRestartWindow" meta:"label=Auto Heal Restart Window;type=number;keywords=auto,heal,restart,window,minutes,cooldown,protection;category=internal;description=Time window in minutes for counting auto-heal restarts (default: 30)"`- MaxImageUploadSize SettingVariable `key:"maxImageUploadSize" meta:"label=Max Image Upload Size;type=number;keywords=upload,size,limit,maximum,image,tar,file,megabytes,mb,storage;category=internal;description=Maximum size in MB for image archive uploads (default: 500)"`- GitSyncMaxFiles SettingVariable `key:"gitSyncMaxFiles,envOverride" meta:"label=Git Sync Max Files;type=number;keywords=git,sync,files,limit,repository,compose,gitops;category=general;description=Maximum number of repository files copied during a Git sync. Set 0 to disable the environment cap (default: 500)"`- GitSyncMaxTotalSizeMb SettingVariable `key:"gitSyncMaxTotalSizeMb,envOverride" meta:"label=Git Sync Max Total Size (MB);type=number;keywords=git,sync,size,limit,repository,compose,gitops,mb;category=general;description=Maximum combined size in MB for files copied during a Git sync. Set 0 to disable the environment cap (default: 50)"`- GitSyncMaxBinarySizeMb SettingVariable `key:"gitSyncMaxBinarySizeMb,envOverride" meta:"label=Git Sync Max Binary Size (MB);type=number;keywords=git,sync,binary,size,limit,repository,compose,gitops,mb;category=general;description=Maximum size in MB for a single binary file copied during a Git sync. Set 0 to disable the environment cap (default: 10)"`- DockerHost SettingVariable `key:"dockerHost,public,envOverride" meta:"label=Docker Host;type=text;keywords=docker,host,daemon,socket,unix,remote;category=internal;description=URI for Docker daemon"`- BuildProvider SettingVariable `key:"buildProvider,envOverride" meta:"label=Build Provider;type=select;keywords=build,buildkit,depot,provider,remote,local;category=build;description=Default build provider (local or depot)" catmeta:"id=build;title=Build;icon=code;url=/settings/builds;description=Configure BuildKit and Depot build settings"`- BuildsDirectory SettingVariable `key:"buildsDirectory,envOverride" meta:"label=Builds Directory;type=text;keywords=builds,directory,path,workspace,context;category=build;description=Root directory for manual build workspaces"`- BuildTimeout SettingVariable `key:"buildTimeout,envOverride" meta:"label=Build Timeout;type=number;keywords=build,timeout,seconds,buildkit;category=build;description=Timeout for BuildKit builds in seconds (default: 1800 = 30 minutes)"`- DepotProjectId SettingVariable `key:"depotProjectId,envOverride" meta:"label=Depot Project ID;type=text;keywords=depot,project,id,build,provider;category=build;description=Depot project identifier"`- DepotToken SettingVariable `key:"depotToken,envOverride,sensitive" meta:"label=Depot Token;type=password;keywords=depot,token,api,secret,build,provider;category=build;description=Depot API token"`+ // Deprecated: Use the granular prune mode settings instead.+ PruneMode SettingVariable `key:"dockerPruneMode,internal,deprecated" meta:"label=Legacy Docker Prune Action;type=select;keywords=prune,cleanup,clean,remove,delete,unused,dangling,space,disk,legacy;category=internal;description=Legacy prune mode retained for compatibility and migration"`+ DefaultDeployPullPolicy SettingVariable `key:"defaultDeployPullPolicy" meta:"label=Default Deploy Pull Policy;type=select;keywords=deploy,pull,policy,compose,up,missing,always;category=internal;description=Default image pull policy when deploying projects"`+ ScheduledPruneEnabled SettingVariable `key:"scheduledPruneEnabled" meta:"label=Scheduled Prune Enabled;type=boolean;keywords=prune,cleanup,maintenance,schedule,automatic;category=internal;description=Enable scheduled pruning of unused Docker resources"`+ ScheduledPruneInterval SettingVariable `key:"scheduledPruneInterval" meta:"label=Scheduled Prune Interval;type=cron;keywords=prune,cleanup,interval,minutes,schedule;category=internal;description=How often to run scheduled prunes (cron expression)"`+ GitopsSyncInterval SettingVariable `key:"gitopsSyncInterval" meta:"label=GitOps Sync Interval;type=cron;keywords=gitops,sync,interval,frequency,schedule,repository;category=internal;description=How often to run GitOps synchronization checks (cron expression)"`+ // Deprecated: Use pruneContainerMode instead.+ ScheduledPruneContainers SettingVariable `key:"scheduledPruneContainers,deprecated" meta:"label=Legacy Scheduled Prune Containers;type=boolean;keywords=prune,containers,cleanup,maintenance,legacy;category=internal;description=Legacy boolean container prune flag retained for migration compatibility"`+ // Deprecated: Use pruneImageMode instead.+ ScheduledPruneImages SettingVariable `key:"scheduledPruneImages,deprecated" meta:"label=Legacy Scheduled Prune Images;type=boolean;keywords=prune,images,cleanup,maintenance,legacy;category=internal;description=Legacy boolean image prune flag retained for migration compatibility"`+ // Deprecated: Use pruneVolumeMode instead.+ ScheduledPruneVolumes SettingVariable `key:"scheduledPruneVolumes,deprecated" meta:"label=Legacy Scheduled Prune Volumes;type=boolean;keywords=prune,volumes,cleanup,maintenance,legacy;category=internal;description=Legacy boolean volume prune flag retained for migration compatibility"`+ // Deprecated: Use pruneNetworkMode instead.+ ScheduledPruneNetworks SettingVariable `key:"scheduledPruneNetworks,deprecated" meta:"label=Legacy Scheduled Prune Networks;type=boolean;keywords=prune,networks,cleanup,maintenance,legacy;category=internal;description=Legacy boolean network prune flag retained for migration compatibility"`+ // Deprecated: Use pruneBuildCacheMode instead.+ ScheduledPruneBuildCache SettingVariable `key:"scheduledPruneBuildCache,deprecated" meta:"label=Legacy Scheduled Prune Build Cache;type=boolean;keywords=prune,build cache,cleanup,maintenance,legacy;category=internal;description=Legacy boolean build cache prune flag retained for migration compatibility"`+ PruneContainerMode SettingVariable `key:"pruneContainerMode" meta:"label=Prune Containers;type=select;keywords=prune,containers,cleanup,maintenance,mode,older,stopped;category=internal;description=Select how containers should be pruned when the scheduled prune job runs"`+ PruneContainerUntil SettingVariable `key:"pruneContainerUntil" meta:"label=Container Age Filter;type=text;keywords=prune,containers,cleanup,maintenance,until,older,duration;category=internal;description=Duration threshold for scheduled container prune when mode is olderThan"`+ PruneImageMode SettingVariable `key:"pruneImageMode" meta:"label=Prune Images;type=select;keywords=prune,images,cleanup,maintenance,mode,dangling,all,older;category=internal;description=Select how images should be pruned when the scheduled prune job runs"`+ PruneImageUntil SettingVariable `key:"pruneImageUntil" meta:"label=Image Age Filter;type=text;keywords=prune,images,cleanup,maintenance,until,older,duration;category=internal;description=Duration threshold for scheduled image prune when mode is olderThan"`+ PruneVolumeMode SettingVariable `key:"pruneVolumeMode" meta:"label=Prune Volumes;type=select;keywords=prune,volumes,cleanup,maintenance,mode,anonymous,named;category=internal;description=Select how volumes should be pruned when the scheduled prune job runs"`+ PruneNetworkMode SettingVariable `key:"pruneNetworkMode" meta:"label=Prune Networks;type=select;keywords=prune,networks,cleanup,maintenance,mode,unused,older;category=internal;description=Select how networks should be pruned when the scheduled prune job runs"`+ PruneNetworkUntil SettingVariable `key:"pruneNetworkUntil" meta:"label=Network Age Filter;type=text;keywords=prune,networks,cleanup,maintenance,until,older,duration;category=internal;description=Duration threshold for scheduled network prune when mode is olderThan"`+ PruneBuildCacheMode SettingVariable `key:"pruneBuildCacheMode" meta:"label=Prune Build Cache;type=select;keywords=prune,build cache,cleanup,maintenance,mode,unused,all,older;category=internal;description=Select how build cache should be pruned when the scheduled prune job runs"`+ PruneBuildCacheUntil SettingVariable `key:"pruneBuildCacheUntil" meta:"label=Build Cache Age Filter;type=text;keywords=prune,build cache,cleanup,maintenance,until,older,duration;category=internal;description=Duration threshold for scheduled build cache prune when mode is olderThan"`+ AutoHealEnabled SettingVariable `key:"autoHealEnabled" meta:"label=Auto Heal;type=boolean;keywords=auto,heal,health,restart,unhealthy,recovery,container,healthcheck;category=internal;description=Automatically restart containers that become unhealthy"`+ AutoHealInterval SettingVariable `key:"autoHealInterval" meta:"label=Auto Heal Interval;type=cron;keywords=auto,heal,interval,frequency,schedule,health,jobs;description=How often to check container health (cron expression)" catmeta:"id=jobschedule"`+ AutoHealExcludedContainers SettingVariable `key:"autoHealExcludedContainers" meta:"label=Auto Heal Excluded Containers;type=text;keywords=auto,heal,exclude,containers,ignore,skip,health;category=internal;description=Comma-separated list of containers to exclude from auto-heal"`+ AutoHealMaxRestarts SettingVariable `key:"autoHealMaxRestarts" meta:"label=Auto Heal Max Restarts;type=number;keywords=auto,heal,max,restarts,limit,loop,protection;category=internal;description=Maximum auto-heal restarts per container within the restart window (default: 5)"`+ AutoHealRestartWindow SettingVariable `key:"autoHealRestartWindow" meta:"label=Auto Heal Restart Window;type=number;keywords=auto,heal,restart,window,minutes,cooldown,protection;category=internal;description=Time window in minutes for counting auto-heal restarts (default: 30)"`+ MaxImageUploadSize SettingVariable `key:"maxImageUploadSize" meta:"label=Max Image Upload Size;type=number;keywords=upload,size,limit,maximum,image,tar,file,megabytes,mb,storage;category=internal;description=Maximum size in MB for image archive uploads (default: 500)"`+ GitSyncMaxFiles SettingVariable `key:"gitSyncMaxFiles,envOverride" meta:"label=Git Sync Max Files;type=number;keywords=git,sync,files,limit,repository,compose,gitops;category=general;description=Maximum number of repository files copied during a Git sync. Set 0 to disable the environment cap (default: 500)"`+ GitSyncMaxTotalSizeMb SettingVariable `key:"gitSyncMaxTotalSizeMb,envOverride" meta:"label=Git Sync Max Total Size (MB);type=number;keywords=git,sync,size,limit,repository,compose,gitops,mb;category=general;description=Maximum combined size in MB for files copied during a Git sync. Set 0 to disable the environment cap (default: 50)"`+ GitSyncMaxBinarySizeMb SettingVariable `key:"gitSyncMaxBinarySizeMb,envOverride" meta:"label=Git Sync Max Binary Size (MB);type=number;keywords=git,sync,binary,size,limit,repository,compose,gitops,mb;category=general;description=Maximum size in MB for a single binary file copied during a Git sync. Set 0 to disable the environment cap (default: 10)"`+ DockerHost SettingVariable `key:"dockerHost,public,envOverride" meta:"label=Docker Host;type=text;keywords=docker,host,daemon,socket,unix,remote;category=internal;description=URI for Docker daemon"`+ BuildProvider SettingVariable `key:"buildProvider,envOverride" meta:"label=Build Provider;type=select;keywords=build,buildkit,depot,provider,remote,local;category=build;description=Default build provider (local or depot)" catmeta:"id=build;title=Build;icon=code;url=/settings/builds;description=Configure BuildKit and Depot build settings"`+ BuildsDirectory SettingVariable `key:"buildsDirectory,envOverride" meta:"label=Builds Directory;type=text;keywords=builds,directory,path,workspace,context;category=build;description=Root directory for manual build workspaces"`+ BuildTimeout SettingVariable `key:"buildTimeout,envOverride" meta:"label=Build Timeout;type=number;keywords=build,timeout,seconds,buildkit;category=build;description=Timeout for BuildKit builds in seconds (default: 1800 = 30 minutes)"`+ DepotProjectId SettingVariable `key:"depotProjectId,envOverride" meta:"label=Depot Project ID;type=text;keywords=depot,project,id,build,provider;category=build;description=Depot project identifier"`+ DepotToken SettingVariable `key:"depotToken,envOverride,sensitive" meta:"label=Depot Token;type=password;keywords=depot,token,api,secret,build,provider;category=build;description=Depot API token"`// Authentication and security categoriesAuthLocalEnabled SettingVariable `key:"authLocalEnabled,public" meta:"label=Local Authentication;type=boolean;keywords=local,auth,authentication,username,password,login,credentials;category=authentication;description=Enable local username/password authentication" catmeta:"id=authentication;title=Authentication;icon=lock;url=/settings/authentication;description=Manage authentication providers, password policy, and session behavior"`diff --git a/backend/internal/services/dashboard_service.go b/backend/internal/services/dashboard_service.goindex bbc60a6a6..1273af099 100644--- a/backend/internal/services/dashboard_service.go+++ b/backend/internal/services/dashboard_service.go@@ -150,9 +150,7 @@ func (s *DashboardService) GetSnapshot(ctx context.Context, options DashboardAct},ImageUsageCounts: imageUsageCounts,ActionItems: *actionItems,- Settings: dashboardtypes.SnapshotSettings{- DockerPruneMode: s.getDashboardDockerPruneModeInternal(ctx),- },+ Settings: dashboardtypes.SnapshotSettings{},}, nil}@@ -403,14 +401,6 @@ func (s *DashboardService) getPendingImageUpdatesCountForImageIDs(ctx context.Coreturn int(count), nil}-func (s *DashboardService) getDashboardDockerPruneModeInternal(ctx context.Context) string {- if s.settingsService == nil {- return "dangling"- }-- return s.settingsService.GetStringSetting(ctx, "dockerPruneMode", "dangling")-}-func (s *DashboardService) getActionableVulnerabilitiesCountInternal(ctx context.Context) (int, error) {if s.vulnerabilityService == nil {return 0, nildiff --git a/backend/internal/services/dashboard_service_test.go b/backend/internal/services/dashboard_service_test.goindex f1f6db0e8..aff473afb 100644--- a/backend/internal/services/dashboard_service_test.go+++ b/backend/internal/services/dashboard_service_test.go@@ -218,7 +218,7 @@ func TestDashboardService_GetSnapshot_ReturnsDashboardSnapshot(t *testing.T) {require.Equal(t, 1, snapshot.ImageUsageCounts.Unused)require.Equal(t, 3, snapshot.ImageUsageCounts.Total)require.EqualValues(t, 525, snapshot.ImageUsageCounts.TotalSize)- require.Equal(t, "dangling", snapshot.Settings.DockerPruneMode)+ require.Equal(t, dashboardtypes.SnapshotSettings{}, snapshot.Settings)require.ElementsMatch(t, []dashboardtypes.ActionItem{{Kind: dashboardtypes.ActionItemKindStoppedContainers, Count: 1, Severity: dashboardtypes.ActionItemSeverityWarning},diff --git a/backend/internal/services/image_service.go b/backend/internal/services/image_service.goindex b31ef3858..30c6159df 100644--- a/backend/internal/services/image_service.go+++ b/backend/internal/services/image_service.go@@ -16,6 +16,7 @@ import (utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry""github.com/getarcaneapp/arcane/types/containerregistry"imagetypes "github.com/getarcaneapp/arcane/types/image"+ systemtypes "github.com/getarcaneapp/arcane/types/system""github.com/getarcaneapp/arcane/types/vulnerability""github.com/moby/moby/api/types/container""github.com/moby/moby/api/types/image"@@ -366,17 +367,27 @@ func isUnauthorizedPullErrorInternal(err error) bool {return false}-func (s *ImageService) PruneImages(ctx context.Context, dangling bool) (*image.PruneReport, error) {+func (s *ImageService) PruneImages(ctx context.Context, options systemtypes.PruneImagesOptions) (*image.PruneReport, error) {dockerClient, err := s.dockerService.GetClient(ctx)if err != nil {return nil, fmt.Errorf("failed to connect to Docker: %w", err)}filterArgs := make(client.Filters)- if dangling {+ switch options.Mode {+ case systemtypes.PruneImageModeNone:+ return nil, fmt.Errorf("image prune mode none is not allowed")+ case systemtypes.PruneImageModeDangling:filterArgs = filterArgs.Add("dangling", "true")- } else {+ case systemtypes.PruneImageModeAll:filterArgs = filterArgs.Add("dangling", "false")+ case systemtypes.PruneImageModeOlderThan:+ if strings.TrimSpace(options.Until) == "" {+ return nil, fmt.Errorf("image prune mode olderThan requires until")+ }+ filterArgs = filterArgs.Add("until", options.Until)+ default:+ return nil, fmt.Errorf("unsupported image prune mode: %s", options.Mode)}report, err := dockerClient.ImagePrune(ctx, client.ImagePruneOptions{Filters: filterArgs})@@ -392,7 +403,8 @@ func (s *ImageService) PruneImages(ctx context.Context, dangling bool) (*image.Pmetadata := models.JSON{"action": "prune",- "dangling": dangling,+ "mode": options.Mode,+ "until": options.Until,"imagesDeleted": len(pruneReport.ImagesDeleted),"spaceReclaimed": pruneReport.SpaceReclaimed,}diff --git a/backend/internal/services/settings_service.go b/backend/internal/services/settings_service.goindex 49b01ef6f..ddfa54e7e 100644--- a/backend/internal/services/settings_service.go+++ b/backend/internal/services/settings_service.go@@ -106,15 +106,24 @@ func DefaultSettingsConfig() *models.Settings {PollingInterval: models.SettingVariable{Value: "0 0 * * * *"},EventCleanupInterval: models.SettingVariable{Value: "0 0 */6 * * *"},AutoInjectEnv: models.SettingVariable{Value: "false"},- PruneMode: models.SettingVariable{Value: "dangling"},+ PruneMode: models.SettingVariable{Value: "dangling"}, //nolint:staticcheck // Legacy prune setting is still seeded for migration compatibility.DefaultDeployPullPolicy: models.SettingVariable{Value: "missing"},ScheduledPruneEnabled: models.SettingVariable{Value: "false"},ScheduledPruneInterval: models.SettingVariable{Value: "0 0 0 * * *"},- ScheduledPruneContainers: models.SettingVariable{Value: "true"},- ScheduledPruneImages: models.SettingVariable{Value: "true"},- ScheduledPruneVolumes: models.SettingVariable{Value: "false"},- ScheduledPruneNetworks: models.SettingVariable{Value: "true"},- ScheduledPruneBuildCache: models.SettingVariable{Value: "false"},+ ScheduledPruneContainers: models.SettingVariable{Value: "true"}, //nolint:staticcheck // Legacy prune setting is still seeded for migration compatibility.+ ScheduledPruneImages: models.SettingVariable{Value: "true"}, //nolint:staticcheck // Legacy prune setting is still seeded for migration compatibility.+ ScheduledPruneVolumes: models.SettingVariable{Value: "false"}, //nolint:staticcheck // Legacy prune setting is still seeded for migration compatibility.+ ScheduledPruneNetworks: models.SettingVariable{Value: "true"}, //nolint:staticcheck // Legacy prune setting is still seeded for migration compatibility.+ ScheduledPruneBuildCache: models.SettingVariable{Value: "false"}, //nolint:staticcheck // Legacy prune setting is still seeded for migration compatibility.+ PruneContainerMode: models.SettingVariable{Value: "stopped"},+ PruneContainerUntil: models.SettingVariable{Value: ""},+ PruneImageMode: models.SettingVariable{Value: "dangling"},+ PruneImageUntil: models.SettingVariable{Value: ""},+ PruneVolumeMode: models.SettingVariable{Value: "none"},+ PruneNetworkMode: models.SettingVariable{Value: "unused"},+ PruneNetworkUntil: models.SettingVariable{Value: ""},+ PruneBuildCacheMode: models.SettingVariable{Value: "none"},+ PruneBuildCacheUntil: models.SettingVariable{Value: ""},AutoHealEnabled: models.SettingVariable{Value: "false"},AutoHealInterval: models.SettingVariable{Value: "*/30 * * * * *"},AutoHealExcludedContainers: models.SettingVariable{Value: ""},@@ -205,6 +214,22 @@ func (s *SettingsService) loadDatabaseSettingsInternal(ctx context.Context, db *return nil, fmt.Errorf("failed to load configuration from the database: %w", err)}+ updated, err := s.ensureGranularPruneSettingsMigratedInternal(ctx, db, loaded) //nolint:staticcheck // Legacy prune migration remains temporarily for backward compatibility.+ if err != nil {+ return nil, err+ }+ if updated {+ loaded = nil+ queryCtx, queryCancel = context.WithTimeout(ctx, 10*time.Second)+ defer queryCancel()+ err = db.+ WithContext(queryCtx).+ Find(&loaded).Error+ if err != nil {+ return nil, fmt.Errorf("failed to reload configuration from the database after prune migration: %w", err)+ }+ }+for _, v := range loaded {err = dest.UpdateField(v.Key, v.Value, false)@@ -219,6 +244,144 @@ func (s *SettingsService) loadDatabaseSettingsInternal(ctx context.Context, db *return dest, nil}+// Deprecated: This migration path exists only to lift legacy prune settings into the granular model.+func (s *SettingsService) ensureGranularPruneSettingsMigratedInternal(ctx context.Context, db *database.DB, loaded []models.SettingVariable) (bool, error) {+ loadedMap := make(map[string]string, len(loaded))+ for _, setting := range loaded {+ loadedMap[setting.Key] = setting.Value+ }++ missingKeys := []string{+ "pruneContainerMode",+ "pruneContainerUntil",+ "pruneImageMode",+ "pruneImageUntil",+ "pruneVolumeMode",+ "pruneNetworkMode",+ "pruneNetworkUntil",+ "pruneBuildCacheMode",+ "pruneBuildCacheUntil",+ }++ needsMigration := false+ for _, key := range missingKeys {+ if _, ok := loadedMap[key]; !ok {+ needsMigration = true+ break+ }+ }++ if !needsMigration {+ return false, nil+ }++ pruneMode := loadedMap["dockerPruneMode"]+ if pruneMode == "" {+ pruneMode = "dangling"+ }++ valuesToPersist := []models.SettingVariable{+ {Key: "pruneContainerMode", Value: coalesceSettingValueInternal(loadedMap, migrateLegacyContainerPruneModeInternal(loadedMap["scheduledPruneContainers"]), "pruneContainerMode", "scheduledPruneContainerMode")}, //nolint:staticcheck // Legacy prune migration remains temporarily for backward compatibility.+ {Key: "pruneContainerUntil", Value: coalesceSettingValueInternal(loadedMap, "", "pruneContainerUntil", "scheduledPruneContainerUntil")},+ {Key: "pruneImageMode", Value: coalesceSettingValueInternal(loadedMap, migrateLegacyImagePruneModeInternal(pruneMode, loadedMap["scheduledPruneImages"]), "pruneImageMode", "scheduledPruneImageMode")}, //nolint:staticcheck // Legacy prune migration remains temporarily for backward compatibility.+ {Key: "pruneImageUntil", Value: coalesceSettingValueInternal(loadedMap, "", "pruneImageUntil", "scheduledPruneImageUntil")},+ {Key: "pruneVolumeMode", Value: coalesceSettingValueInternal(loadedMap, migrateLegacyVolumePruneModeInternal(pruneMode, loadedMap["scheduledPruneVolumes"]), "pruneVolumeMode", "scheduledPruneVolumeMode")}, //nolint:staticcheck // Legacy prune migration remains temporarily for backward compatibility.+ {Key: "pruneNetworkMode", Value: coalesceSettingValueInternal(loadedMap, migrateLegacyNetworkPruneModeInternal(loadedMap["scheduledPruneNetworks"]), "pruneNetworkMode", "scheduledPruneNetworkMode")}, //nolint:staticcheck // Legacy prune migration remains temporarily for backward compatibility.+ {Key: "pruneNetworkUntil", Value: coalesceSettingValueInternal(loadedMap, "", "pruneNetworkUntil", "scheduledPruneNetworkUntil")},+ {Key: "pruneBuildCacheMode", Value: coalesceSettingValueInternal(loadedMap, migrateLegacyBuildCachePruneModeInternal(pruneMode, loadedMap["scheduledPruneBuildCache"]), "pruneBuildCacheMode", "scheduledPruneBuildCacheMode")}, //nolint:staticcheck // Legacy prune migration remains temporarily for backward compatibility.+ {Key: "pruneBuildCacheUntil", Value: coalesceSettingValueInternal(loadedMap, "", "pruneBuildCacheUntil", "scheduledPruneBuildCacheUntil")},+ }++ if err := db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {+ for _, value := range valuesToPersist {+ if _, ok := loadedMap[value.Key]; ok {+ continue+ }+ if err := tx.Save(&value).Error; err != nil {+ return fmt.Errorf("failed to persist migrated prune setting %s: %w", value.Key, err)+ }+ }+ return nil+ }); err != nil {+ return false, fmt.Errorf("failed to migrate granular prune settings: %w", err)+ }++ slog.InfoContext(ctx, "migrated legacy prune settings to granular prune settings")+ return true, nil+}++// Deprecated: This migration helper exists only to translate legacy prune settings.+func migrateLegacyContainerPruneModeInternal(legacyValue string) string {+ if isLegacyPruneEnabledInternal(legacyValue, true) {+ return "stopped"+ }+ return "none"+}++// Deprecated: This migration helper exists only to translate legacy prune settings.+func migrateLegacyImagePruneModeInternal(pruneMode, legacyValue string) string {+ if !isLegacyPruneEnabledInternal(legacyValue, true) {+ return "none"+ }+ if pruneMode == "all" {+ return "all"+ }+ return "dangling"+}++// Deprecated: This migration helper exists only to translate legacy prune settings.+func migrateLegacyVolumePruneModeInternal(pruneMode, legacyValue string) string {+ if !isLegacyPruneEnabledInternal(legacyValue, false) {+ return "none"+ }+ if pruneMode == "all" {+ return "all"+ }+ return "anonymous"+}++// Deprecated: This migration helper exists only to translate legacy prune settings.+func migrateLegacyNetworkPruneModeInternal(legacyValue string) string {+ if isLegacyPruneEnabledInternal(legacyValue, true) {+ return "unused"+ }+ return "none"+}++// Deprecated: This migration helper exists only to translate legacy prune settings.+func migrateLegacyBuildCachePruneModeInternal(pruneMode, legacyValue string) string {+ if !isLegacyPruneEnabledInternal(legacyValue, false) {+ return "none"+ }+ if pruneMode == "all" {+ return "all"+ }+ return "unused"+}++func isLegacyPruneEnabledInternal(value string, defaultValue bool) bool {+ if strings.TrimSpace(value) == "" {+ return defaultValue+ }++ parsed, err := strconv.ParseBool(value)+ if err != nil {+ return defaultValue+ }++ return parsed+}++func coalesceSettingValueInternal(loadedMap map[string]string, fallback string, keys ...string) string {+ for _, key := range keys {+ if value, ok := loadedMap[key]; ok {+ return value+ }+ }++ return fallback+}+func (s *SettingsService) loadDatabaseConfigFromEnv(ctx context.Context, db *database.DB) (*models.Settings, error) {dest := s.getDefaultSettings()@@ -595,7 +758,13 @@ func (s *SettingsService) prepareUpdateValues(updates settings.Update, cfg, defachangedPolling = truecase "autoUpdate", "autoUpdateInterval":changedAutoUpdate = true- case "scheduledPruneEnabled", "scheduledPruneInterval", "scheduledPruneContainers", "scheduledPruneImages", "scheduledPruneVolumes", "scheduledPruneNetworks", "scheduledPruneBuildCache":+ case "scheduledPruneEnabled",+ "scheduledPruneInterval",+ "scheduledPruneContainers",+ "scheduledPruneImages",+ "scheduledPruneVolumes",+ "scheduledPruneNetworks",+ "scheduledPruneBuildCache":changedScheduledPrune = truecase "vulnerabilityScanEnabled", "vulnerabilityScanInterval", "trivyNetwork", "trivySecurityOpts", "trivyPrivileged", "trivyResourceLimitsEnabled", "trivyCpuLimit", "trivyMemoryLimitMb", "trivyConcurrentScanContainers":changedVulnerabilityScan = truediff --git a/backend/internal/services/settings_service_test.go b/backend/internal/services/settings_service_test.goindex 5d1940456..0217b8070 100644--- a/backend/internal/services/settings_service_test.go+++ b/backend/internal/services/settings_service_test.go@@ -129,6 +129,80 @@ func TestSettingsService_GetSettings_UsesCachedSnapshotWithoutDatabase(t *testinrequire.Equal(t, "http://cached", settings.BaseServerURL.Value)}+func TestSettingsService_LoadDatabaseSettings_MigratesLegacyPruneSettings(t *testing.T) {+ ctx := context.Background()+ t.Setenv("UI_CONFIGURATION_DISABLED", "false")+ t.Setenv("AGENT_MODE", "false")+ t.Setenv("EDGE_AGENT", "false")++ tests := []struct {+ name string+ legacy []models.SettingVariable+ assertCfg func(t *testing.T, cfg *models.Settings)+ }{+ {+ name: "maps all prune mode to aggressive resource modes",+ legacy: []models.SettingVariable{+ {Key: "dockerPruneMode", Value: "all"},+ {Key: "scheduledPruneContainers", Value: "true"},+ {Key: "scheduledPruneImages", Value: "true"},+ {Key: "scheduledPruneVolumes", Value: "true"},+ {Key: "scheduledPruneNetworks", Value: "true"},+ {Key: "scheduledPruneBuildCache", Value: "true"},+ },+ assertCfg: func(t *testing.T, cfg *models.Settings) {+ require.Equal(t, "stopped", cfg.PruneContainerMode.Value)+ require.Equal(t, "all", cfg.PruneImageMode.Value)+ require.Equal(t, "all", cfg.PruneVolumeMode.Value)+ require.Equal(t, "unused", cfg.PruneNetworkMode.Value)+ require.Equal(t, "all", cfg.PruneBuildCacheMode.Value)+ },+ },+ {+ name: "uses dangling defaults when legacy booleans are missing",+ legacy: []models.SettingVariable{+ {Key: "dockerPruneMode", Value: "dangling"},+ },+ assertCfg: func(t *testing.T, cfg *models.Settings) {+ require.Equal(t, "stopped", cfg.PruneContainerMode.Value)+ require.Equal(t, "dangling", cfg.PruneImageMode.Value)+ require.Equal(t, "none", cfg.PruneVolumeMode.Value)+ require.Equal(t, "unused", cfg.PruneNetworkMode.Value)+ require.Equal(t, "none", cfg.PruneBuildCacheMode.Value)+ },+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ db := setupSettingsTestDB(t)+ require.NoError(t, db.DB.Create(&tt.legacy).Error)++ svc := &SettingsService{db: db}+ cfg, err := svc.loadDatabaseSettingsInternal(ctx, db)+ require.NoError(t, err)++ tt.assertCfg(t, cfg)++ for _, key := range []string{+ "pruneContainerMode",+ "pruneContainerUntil",+ "pruneImageMode",+ "pruneImageUntil",+ "pruneVolumeMode",+ "pruneNetworkMode",+ "pruneNetworkUntil",+ "pruneBuildCacheMode",+ "pruneBuildCacheUntil",+ } {+ var setting models.SettingVariable+ err := db.DB.Where("key = ?", key).First(&setting).Error+ require.NoErrorf(t, err, "expected migrated key %s to be persisted", key)+ }+ })+ }+}+func TestSettingsService_PruneUnknownSettings_RemovesStaleKeys(t *testing.T) {ctx := context.Background()db := setupSettingsTestDB(t)@@ -341,11 +415,10 @@ func TestSettingsService_UpdateSetting(t *testing.T) {svc, err := NewSettingsService(ctx, db)require.NoError(t, err)- // Use an existing key ("pruneMode") instead of a non-existent one- require.NoError(t, svc.UpdateSetting(ctx, "pruneMode", "all"))+ require.NoError(t, svc.UpdateSetting(ctx, "pruneImageMode", "all"))var sv models.SettingVariable- require.NoError(t, svc.db.WithContext(ctx).Where("key = ?", "pruneMode").First(&sv).Error)+ require.NoError(t, svc.db.WithContext(ctx).Where("key = ?", "pruneImageMode").First(&sv).Error)require.Equal(t, "all", sv.Value)}@@ -365,6 +438,46 @@ func TestSettingsService_UpdateSetting_RefreshesCachedSnapshot(t *testing.T) {require.Equal(t, "https://arcane.test", settings.BaseServerURL.Value)}+func TestSettingsService_UpdateSettings_PruneModesDoNotTriggerScheduledPruneCallback(t *testing.T) {+ ctx := context.Background()+ db := setupSettingsTestDB(t)+ svc, err := NewSettingsService(ctx, db)+ require.NoError(t, err)++ callbackCalls := 0+ svc.OnScheduledPruneSettingsChanged = func(context.Context) {+ callbackCalls+++ }++ imageMode := "all"+ containerUntil := "24h"+ _, err = svc.UpdateSettings(ctx, settings.Update{+ PruneImageMode: &imageMode,+ PruneContainerUntil: &containerUntil,+ })+ require.NoError(t, err)+ require.Equal(t, 0, callbackCalls)+}++func TestSettingsService_UpdateSettings_ScheduledPruneScheduleTriggersCallback(t *testing.T) {+ ctx := context.Background()+ db := setupSettingsTestDB(t)+ svc, err := NewSettingsService(ctx, db)+ require.NoError(t, err)++ callbackCalls := 0+ svc.OnScheduledPruneSettingsChanged = func(context.Context) {+ callbackCalls+++ }++ enabled := "true"+ _, err = svc.UpdateSettings(ctx, settings.Update{+ ScheduledPruneEnabled: &enabled,+ })+ require.NoError(t, err)+ require.Equal(t, 1, callbackCalls)+}+func BenchmarkSettingsService_GetSettings(b *testing.B) {ctx := context.Background()db, err := gorm.Open(glsqlite.Open(":memory:"), &gorm.Config{})diff --git a/backend/internal/services/system_service.go b/backend/internal/services/system_service.goindex 6119499c8..f99bd5ab8 100644--- a/backend/internal/services/system_service.go+++ b/backend/internal/services/system_service.go@@ -55,15 +55,21 @@ var systemUser = models.User{}func (s *SystemService) PruneAll(ctx context.Context, req system.PruneAllRequest) (*system.PruneAllResult, error) {- slog.InfoContext(ctx, "Starting selective prune operation", "containers", req.Containers, "images", req.Images, "volumes", req.Volumes, "networks", req.Networks, "build_cache", req.BuildCache, "dangling", req.Dangling)+ slog.InfoContext(ctx, "Starting selective prune operation",+ "containers", req.Containers,+ "images", req.Images,+ "volumes", req.Volumes,+ "networks", req.Networks,+ "build_cache", req.BuildCache,+ )result := &system.PruneAllResult{Success: true}var mu sync.Mutex// 1. Prune Containers first (sequential) as it may free up other resources- if req.Containers {- slog.InfoContext(ctx, "Pruning stopped containers...")- if err := s.pruneContainers(ctx, result); err != nil {+ if req.Containers != nil && req.Containers.Mode != system.PruneContainerModeNone {+ slog.InfoContext(ctx, "Pruning containers...", "mode", req.Containers.Mode, "until", req.Containers.Until)+ if err := s.pruneContainersInternal(ctx, *req.Containers, result); err != nil {result.Errors = append(result.Errors, fmt.Sprintf("Container pruning failed: %v", err))result.Success = false}@@ -72,16 +78,11 @@ func (s *SystemService) PruneAll(ctx context.Context, req system.PruneAllRequest// 2. Prune other resources in parallelg, groupCtx := errgroup.WithContext(ctx)- if req.Images {+ if req.Images != nil && req.Images.Mode != system.PruneImageModeNone {g.Go(func() error {- danglingOnly := req.Dangling- if settingsDangling, _ := s.getDanglingModeFromSettings(groupCtx); settingsDangling != danglingOnly {- slog.DebugContext(groupCtx, "Prune request overriding stored image prune mode", "settings_dangling_only", settingsDangling, "request_dangling_only", danglingOnly)- }-- slog.InfoContext(groupCtx, "Pruning images...", "dangling_only", danglingOnly)+ slog.InfoContext(groupCtx, "Pruning images...", "mode", req.Images.Mode, "until", req.Images.Until)localResult := &system.PruneAllResult{}- if err := s.pruneImages(groupCtx, danglingOnly, localResult); err != nil {+ if err := s.pruneImagesInternal(groupCtx, *req.Images, localResult); err != nil {mu.Lock()result.Errors = append(result.Errors, fmt.Sprintf("Image pruning failed: %v", err))result.Success = false@@ -97,11 +98,11 @@ func (s *SystemService) PruneAll(ctx context.Context, req system.PruneAllRequest})}- if req.BuildCache {+ if req.BuildCache != nil && req.BuildCache.Mode != system.PruneBuildCacheModeNone {g.Go(func() error {- slog.InfoContext(groupCtx, "Pruning build cache...")+ slog.InfoContext(groupCtx, "Pruning build cache...", "mode", req.BuildCache.Mode, "until", req.BuildCache.Until)localResult := &system.PruneAllResult{}- if err := s.pruneBuildCache(groupCtx, localResult, !req.Dangling); err != nil {+ if err := s.pruneBuildCacheInternal(groupCtx, *req.BuildCache, localResult); err != nil {slog.WarnContext(groupCtx, "Build cache pruning encountered an error", "error", err.Error())// Build cache errors are often non-critical, but we log them} else {@@ -114,11 +115,11 @@ func (s *SystemService) PruneAll(ctx context.Context, req system.PruneAllRequest})}- if req.Volumes {+ if req.Volumes != nil && req.Volumes.Mode != system.PruneVolumeModeNone {g.Go(func() error {- slog.InfoContext(groupCtx, "Pruning unused volumes...")+ slog.InfoContext(groupCtx, "Pruning volumes...", "mode", req.Volumes.Mode)localResult := &system.PruneAllResult{}- if err := s.pruneVolumes(groupCtx, localResult); err != nil {+ if err := s.pruneVolumesInternal(groupCtx, *req.Volumes, localResult); err != nil {mu.Lock()result.Errors = append(result.Errors, fmt.Sprintf("Volume pruning failed: %v", err))result.Success = false@@ -134,11 +135,11 @@ func (s *SystemService) PruneAll(ctx context.Context, req system.PruneAllRequest})}- if req.Networks {+ if req.Networks != nil && req.Networks.Mode != system.PruneNetworkModeNone {g.Go(func() error {- slog.InfoContext(groupCtx, "Pruning unused networks...")+ slog.InfoContext(groupCtx, "Pruning networks...", "mode", req.Networks.Mode, "until", req.Networks.Until)localResult := &system.PruneAllResult{}- if err := s.pruneNetworks(groupCtx, localResult); err != nil {+ if err := s.pruneNetworksInternal(groupCtx, *req.Networks, localResult); err != nil {mu.Lock()result.Errors = append(result.Errors, fmt.Sprintf("Network pruning failed: %v", err))result.Success = false@@ -161,19 +162,6 @@ func (s *SystemService) PruneAll(ctx context.Context, req system.PruneAllRequestreturn result, nil}-func (s *SystemService) getDanglingModeFromSettings(ctx context.Context) (bool, error) {- pruneMode := s.settingsService.GetStringSetting(ctx, "dockerPruneMode", "dangling")-- switch pruneMode {- case "dangling":- return true, nil- case "all":- return false, nil- default:- return true, nil- }-}-func (s *SystemService) performBatchContainerAction(ctx context.Context, containers []container.Summary, actionName string, shouldProcess func(container.Summary) bool, action func(context.Context, string) error) *containertypes.ActionResult {result := &containertypes.ActionResult{Success: true}var mu sync.Mutex@@ -264,13 +252,19 @@ func (s *SystemService) StopAllContainers(ctx context.Context) (*containertypes.}), nil}-func (s *SystemService) pruneContainers(ctx context.Context, result *system.PruneAllResult) error {+func (s *SystemService) pruneContainersInternal(ctx context.Context, options system.PruneContainersOptions, result *system.PruneAllResult) error {dockerClient, err := s.dockerService.GetClient(ctx)if err != nil {return fmt.Errorf("failed to connect to Docker: %w", err)}filterArgs := make(client.Filters)+ if options.Mode == system.PruneContainerModeOlderThan {+ if strings.TrimSpace(options.Until) == "" {+ return fmt.Errorf("container prune mode olderThan requires until")+ }+ filterArgs = filterArgs.Add("until", options.Until)+ }report, err := dockerClient.ContainerPrune(ctx, client.ContainerPruneOptions{Filters: filterArgs})if err != nil {@@ -283,24 +277,28 @@ func (s *SystemService) pruneContainers(ctx context.Context, result *system.Prunreturn nil}-func (s *SystemService) pruneImages(ctx context.Context, danglingOnly bool, result *system.PruneAllResult) error {- slog.DebugContext(ctx, "Starting image pruning", "dangling_only", danglingOnly)-+func (s *SystemService) pruneImagesInternal(ctx context.Context, options system.PruneImagesOptions, result *system.PruneAllResult) error {dockerClient, err := s.dockerService.GetClient(ctx)if err != nil {return fmt.Errorf("failed to connect to Docker: %w", err)}- var filterArgs client.Filters-- if danglingOnly {- slog.DebugContext(ctx, "Configured to prune only dangling images")- filterArgs = make(client.Filters)+ filterArgs := make(client.Filters)+ switch options.Mode {+ case system.PruneImageModeNone:+ return fmt.Errorf("image prune mode none is not allowed")+ case system.PruneImageModeDangling:filterArgs = filterArgs.Add("dangling", "true")- } else {- slog.DebugContext(ctx, "Configured to prune all unused images (including non-dangling)")- filterArgs = make(client.Filters)+ case system.PruneImageModeAll:+ filterArgs = filterArgs.Add("dangling", "false")+ case system.PruneImageModeOlderThan:+ if strings.TrimSpace(options.Until) == "" {+ return fmt.Errorf("image prune mode olderThan requires until")+ }filterArgs = filterArgs.Add("dangling", "false")+ filterArgs = filterArgs.Add("until", options.Until)+ default:+ return fmt.Errorf("unsupported image prune mode: %s", options.Mode)}report, err := dockerClient.ImagePrune(ctx, client.ImagePruneOptions{Filters: filterArgs})@@ -333,7 +331,7 @@ func (s *SystemService) pruneImages(ctx context.Context, danglingOnly bool, resureturn nil}-func (s *SystemService) pruneBuildCache(ctx context.Context, result *system.PruneAllResult, pruneAllCache bool) error {+func (s *SystemService) pruneBuildCacheInternal(ctx context.Context, options system.PruneBuildCacheOptions, result *system.PruneAllResult) error {dockerClient, err := s.dockerService.GetClient(ctx)if err != nil {result.Errors = append(result.Errors, fmt.Errorf("build cache pruning failed (connection): %w", err).Error())@@ -341,12 +339,19 @@ func (s *SystemService) pruneBuildCache(ctx context.Context, result *system.Prunreturn fmt.Errorf("failed to connect to Docker for build cache prune: %w", err)}- options := client.BuildCachePruneOptions{- All: pruneAllCache,+ pruneOptions := client.BuildCachePruneOptions{+ All: options.Mode == system.PruneBuildCacheModeAll,+ }+ if options.Mode == system.PruneBuildCacheModeOlderThan {+ if strings.TrimSpace(options.Until) == "" {+ return fmt.Errorf("build cache prune mode olderThan requires until")+ }+ pruneOptions.Filters = make(client.Filters)+ pruneOptions.Filters = pruneOptions.Filters.Add("until", options.Until)}- slog.DebugContext(ctx, "starting build cache pruning", "prune_all", pruneAllCache)- report, err := dockerClient.BuildCachePrune(ctx, options)+ slog.DebugContext(ctx, "starting build cache pruning", "mode", options.Mode, "until", options.Until)+ report, err := dockerClient.BuildCachePrune(ctx, pruneOptions)if err != nil {result.Errors = append(result.Errors, fmt.Errorf("build cache pruning failed: %w", err).Error())slog.ErrorContext(ctx, "Error pruning build cache", "error", err.Error())@@ -360,12 +365,8 @@ func (s *SystemService) pruneBuildCache(ctx context.Context, result *system.Prunreturn nil}-func (s *SystemService) pruneVolumes(ctx context.Context, result *system.PruneAllResult) error {- // Prune ALL unused volumes (both named and anonymous)- // Note: Docker API only prunes volumes that are NOT in use by any containers (running or stopped)- // With all=true, it will remove both named and anonymous unused volumes- // With all=false, it only removes anonymous (unnamed) unused volumes- allVolumes := true+func (s *SystemService) pruneVolumesInternal(ctx context.Context, options system.PruneVolumesOptions, result *system.PruneAllResult) error {+ allVolumes := options.Mode == system.PruneVolumeModeAllreport, err := s.volumeService.PruneVolumesWithOptions(ctx, allVolumes)if err != nil {return err@@ -379,16 +380,28 @@ func (s *SystemService) pruneVolumes(ctx context.Context, result *system.PruneAlreturn nil}-func (s *SystemService) pruneNetworks(ctx context.Context, result *system.PruneAllResult) error {- // Note: Docker API only prunes networks that are NOT in use by any containers- report, err := s.networkService.PruneNetworks(ctx)+func (s *SystemService) pruneNetworksInternal(ctx context.Context, options system.PruneNetworksOptions, result *system.PruneAllResult) error {+ dockerClient, err := s.dockerService.GetClient(ctx)if err != nil {- return err+ return fmt.Errorf("failed to connect to Docker: %w", err)+ }++ filterArgs := make(client.Filters)+ if options.Mode == system.PruneNetworkModeOlderThan {+ if strings.TrimSpace(options.Until) == "" {+ return fmt.Errorf("network prune mode olderThan requires until")+ }+ filterArgs = filterArgs.Add("until", options.Until)+ }++ report, err := dockerClient.NetworkPrune(ctx, client.NetworkPruneOptions{Filters: filterArgs})+ if err != nil {+ return fmt.Errorf("failed to prune networks: %w", err)}- slog.InfoContext(ctx, "Network prune completed", "networks_deleted", len(report.NetworksDeleted))+ slog.InfoContext(ctx, "Network prune completed", "networks_deleted", len(report.Report.NetworksDeleted))- result.NetworksDeleted = report.NetworksDeleted+ result.NetworksDeleted = report.Report.NetworksDeletedreturn nil}diff --git a/backend/internal/services/volume_service_test.go b/backend/internal/services/volume_service_test.goindex 209d9755e..7749162af 100644--- a/backend/internal/services/volume_service_test.go+++ b/backend/internal/services/volume_service_test.go@@ -130,6 +130,14 @@ func TestBuildVolumePruneOptionsInternal_PreservesTrivyCache(t *testing.T) {require.True(t, options.Filters["label!"][trivyCacheVolumePruneFilterValue])}+func TestBuildVolumePruneOptionsInternal_PreservesTrivyCacheForAnonymousVolumes(t *testing.T) {+ options := buildVolumePruneOptionsInternal(false, true)++ require.False(t, options.All)+ require.NotNil(t, options.Filters)+ require.True(t, options.Filters["label!"][trivyCacheVolumePruneFilterValue])+}+func TestBuildVolumePruneOptionsInternal_DisabledPreservationOmitsFilter(t *testing.T) {options := buildVolumePruneOptionsInternal(true, false)diff --git a/backend/pkg/scheduler/scheduled_prune_job.go b/backend/pkg/scheduler/scheduled_prune_job.goindex 51986bfb0..6b4810ccd 100644--- a/backend/pkg/scheduler/scheduled_prune_job.go+++ b/backend/pkg/scheduler/scheduled_prune_job.go@@ -72,19 +72,9 @@ func (j *ScheduledPruneJob) Run(ctx context.Context) {return}- pruneMode := j.settingsService.GetStringSetting(ctx, "dockerPruneMode", "dangling")- danglingOnly := pruneMode != "all"+ req := buildScheduledPruneRequestInternal(ctx, j.settingsService)- req := system.PruneAllRequest{- Containers: j.settingsService.GetBoolSetting(ctx, "scheduledPruneContainers", true),- Images: j.settingsService.GetBoolSetting(ctx, "scheduledPruneImages", true),- Volumes: j.settingsService.GetBoolSetting(ctx, "scheduledPruneVolumes", false),- Networks: j.settingsService.GetBoolSetting(ctx, "scheduledPruneNetworks", true),- BuildCache: j.settingsService.GetBoolSetting(ctx, "scheduledPruneBuildCache", false),- Dangling: danglingOnly,- }-- if !req.Containers && !req.Images && !req.Volumes && !req.Networks && !req.BuildCache {+ if !hasScheduledPruneTargetsInternal(req) {slog.InfoContext(ctx, "scheduled prune run skipped; no resource types selected")return}@@ -95,7 +85,6 @@ func (j *ScheduledPruneJob) Run(ctx context.Context) {"volumes", req.Volumes,"networks", req.Networks,"build_cache", req.BuildCache,- "dangling_only", req.Dangling,)result, err := j.systemService.PruneAll(ctx, req)@@ -127,3 +116,74 @@ func (j *ScheduledPruneJob) Reschedule(ctx context.Context) error {slog.InfoContext(ctx, "rescheduling scheduled prune job in new scheduler; currently requires restart")return nil}++func buildScheduledPruneRequestInternal(ctx context.Context, settingsService *services.SettingsService) system.PruneAllRequest {+ return system.PruneAllRequest{+ Containers: buildScheduledContainerPruneOptionsInternal(ctx, settingsService),+ Images: buildScheduledImagePruneOptionsInternal(ctx, settingsService),+ Volumes: buildScheduledVolumePruneOptionsInternal(ctx, settingsService),+ Networks: buildScheduledNetworkPruneOptionsInternal(ctx, settingsService),+ BuildCache: buildScheduledBuildCachePruneOptionsInternal(ctx, settingsService),+ }+}++func hasScheduledPruneTargetsInternal(req system.PruneAllRequest) bool {+ return req.Containers != nil || req.Images != nil || req.Volumes != nil || req.Networks != nil || req.BuildCache != nil+}++func buildScheduledContainerPruneOptionsInternal(ctx context.Context, settingsService *services.SettingsService) *system.PruneContainersOptions {+ mode := settingsService.GetStringSetting(ctx, "pruneContainerMode", "stopped")+ if mode == "" || mode == string(system.PruneContainerModeNone) {+ return nil+ }++ return &system.PruneContainersOptions{+ Mode: system.PruneContainerMode(mode),+ Until: settingsService.GetStringSetting(ctx, "pruneContainerUntil", ""),+ }+}++func buildScheduledImagePruneOptionsInternal(ctx context.Context, settingsService *services.SettingsService) *system.PruneImagesOptions {+ mode := settingsService.GetStringSetting(ctx, "pruneImageMode", "dangling")+ if mode == "" || mode == string(system.PruneImageModeNone) {+ return nil+ }++ return &system.PruneImagesOptions{+ Mode: system.PruneImageMode(mode),+ Until: settingsService.GetStringSetting(ctx, "pruneImageUntil", ""),+ }+}++func buildScheduledVolumePruneOptionsInternal(ctx context.Context, settingsService *services.SettingsService) *system.PruneVolumesOptions {+ mode := settingsService.GetStringSetting(ctx, "pruneVolumeMode", "none")+ if mode == "" || mode == string(system.PruneVolumeModeNone) {+ return nil+ }++ return &system.PruneVolumesOptions{Mode: system.PruneVolumeMode(mode)}+}++func buildScheduledNetworkPruneOptionsInternal(ctx context.Context, settingsService *services.SettingsService) *system.PruneNetworksOptions {+ mode := settingsService.GetStringSetting(ctx, "pruneNetworkMode", "unused")+ if mode == "" || mode == string(system.PruneNetworkModeNone) {+ return nil+ }++ return &system.PruneNetworksOptions{+ Mode: system.PruneNetworkMode(mode),+ Until: settingsService.GetStringSetting(ctx, "pruneNetworkUntil", ""),+ }+}++func buildScheduledBuildCachePruneOptionsInternal(ctx context.Context, settingsService *services.SettingsService) *system.PruneBuildCacheOptions {+ mode := settingsService.GetStringSetting(ctx, "pruneBuildCacheMode", "none")+ if mode == "" || mode == string(system.PruneBuildCacheModeNone) {+ return nil+ }++ return &system.PruneBuildCacheOptions{+ Mode: system.PruneBuildCacheMode(mode),+ Until: settingsService.GetStringSetting(ctx, "pruneBuildCacheUntil", ""),+ }+}diff --git a/backend/pkg/scheduler/scheduled_prune_job_test.go b/backend/pkg/scheduler/scheduled_prune_job_test.gonew file mode 100644index 000000000..57cc857f4--- /dev/null+++ b/backend/pkg/scheduler/scheduled_prune_job_test.go@@ -0,0 +1,80 @@+package scheduler++import (+ "context"+ "testing"++ glsqlite "github.com/glebarez/sqlite"+ "github.com/stretchr/testify/require"+ "gorm.io/gorm"++ "github.com/getarcaneapp/arcane/backend/internal/database"+ "github.com/getarcaneapp/arcane/backend/internal/models"+ "github.com/getarcaneapp/arcane/backend/internal/services"+ "github.com/getarcaneapp/arcane/types/system"+)++func setupScheduledPruneSettingsServiceInternal(t *testing.T) *services.SettingsService {+ t.Helper()++ db, err := gorm.Open(glsqlite.Open(":memory:"), &gorm.Config{})+ require.NoError(t, err)+ require.NoError(t, db.AutoMigrate(&models.SettingVariable{}))++ svc, err := services.NewSettingsService(context.Background(), &database.DB{DB: db})+ require.NoError(t, err)++ return svc+}++func TestBuildScheduledPruneRequestInternal(t *testing.T) {+ ctx := context.Background()+ settingsService := setupScheduledPruneSettingsServiceInternal(t)++ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneContainerMode", "olderThan"))+ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneContainerUntil", "24h"))+ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneImageMode", "all"))+ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneVolumeMode", "anonymous"))+ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneNetworkMode", "none"))+ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneBuildCacheMode", "olderThan"))+ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneBuildCacheUntil", "30m"))++ req := buildScheduledPruneRequestInternal(ctx, settingsService)++ require.Equal(t, &system.PruneContainersOptions{+ Mode: system.PruneContainerModeOlderThan,+ Until: "24h",+ }, req.Containers)+ require.Equal(t, &system.PruneImagesOptions{+ Mode: system.PruneImageModeAll,+ }, req.Images)+ require.Equal(t, &system.PruneVolumesOptions{+ Mode: system.PruneVolumeModeAnonymous,+ }, req.Volumes)+ require.Nil(t, req.Networks)+ require.Equal(t, &system.PruneBuildCacheOptions{+ Mode: system.PruneBuildCacheModeOlderThan,+ Until: "30m",+ }, req.BuildCache)+ require.True(t, hasScheduledPruneTargetsInternal(req))+}++func TestBuildScheduledPruneRequestInternal_SkipsWhenAllModesAreNone(t *testing.T) {+ ctx := context.Background()+ settingsService := setupScheduledPruneSettingsServiceInternal(t)++ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneContainerMode", "none"))+ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneImageMode", "none"))+ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneVolumeMode", "none"))+ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneNetworkMode", "none"))+ require.NoError(t, settingsService.UpdateSetting(ctx, "pruneBuildCacheMode", "none"))++ req := buildScheduledPruneRequestInternal(ctx, settingsService)++ require.Nil(t, req.Containers)+ require.Nil(t, req.Images)+ require.Nil(t, req.Volumes)+ require.Nil(t, req.Networks)+ require.Nil(t, req.BuildCache)+ require.False(t, hasScheduledPruneTargetsInternal(req))+}diff --git a/cli/pkg/system/cmd.go b/cli/pkg/system/cmd.goindex 966ad54a5..fed117495 100644--- a/cli/pkg/system/cmd.go+++ b/cli/pkg/system/cmd.go@@ -33,7 +33,13 @@ var pruneCmd = &cobra.Command{return err}- resp, err := c.Post(cmd.Context(), types.Endpoints.SystemPrune(c.EnvID()), nil)+ req := system.PruneAllRequest{+ Containers: &system.PruneContainersOptions{Mode: system.PruneContainerModeStopped},+ Images: &system.PruneImagesOptions{Mode: system.PruneImageModeDangling},+ Networks: &system.PruneNetworksOptions{Mode: system.PruneNetworkModeUnused},+ }++ resp, err := c.Post(cmd.Context(), types.Endpoints.SystemPrune(c.EnvID()), req)if err != nil {return fmt.Errorf("failed to prune: %w", err)}diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex cf18bd764..82541d174 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -199,17 +199,36 @@"scheduled_prune_description": "Automatically clean up unused Docker resources on a schedule","scheduled_prune_interval_label": "Prune Interval","scheduled_prune_interval_description": "Time between automatic prune operations (60-10080 minutes)",+ "prune_options_title": "Prune Options",+ "prune_options_description": "These options define the default prune behavior. The scheduled prune job uses them, and dashboard prune actions can override them per run.",+ "prune_containers_label": "Containers",+ "prune_images_label": "Images",+ "prune_volumes_label": "Volumes",+ "prune_networks_label": "Networks",+ "prune_build_cache_label": "Build Cache","scheduled_prune_containers_label": "Prune Containers",- "scheduled_prune_containers_description": "Remove stopped containers",+ "scheduled_prune_containers_description": "Choose whether to skip, prune stopped containers, or prune containers older than a threshold","scheduled_prune_images_label": "Prune Images",- "scheduled_prune_images_description": "Remove unused images (uses the Docker Prune Mode setting)",+ "scheduled_prune_images_description": "Choose whether to prune dangling images, all unused images, or only older unused images","scheduled_prune_volumes_label": "Prune Volumes",- "scheduled_prune_volumes_description": "Remove unused volumes",+ "scheduled_prune_volumes_description": "Choose whether to prune only anonymous volumes or all unused volumes","scheduled_prune_volumes_warning": "Warning: This may delete important data. Only enable if you're sure.","scheduled_prune_networks_label": "Prune Networks",- "scheduled_prune_networks_description": "Remove unused networks",+ "scheduled_prune_networks_description": "Choose whether to prune unused networks immediately or only older unused networks","scheduled_prune_build_cache_label": "Prune Build Cache",- "scheduled_prune_build_cache_description": "Remove Docker build cache",+ "scheduled_prune_build_cache_description": "Choose whether to prune unused build cache, all build cache, or only older cache entries",+ "prune_mode_none": "None",+ "prune_mode_older_than": "Older Than",+ "prune_volumes_mode_anonymous": "Anonymous Only",+ "prune_volumes_mode_all": "All Unused",+ "prune_build_cache_mode_unused": "Unused Only",+ "prune_build_cache_mode_all": "All Cache",+ "prune_duration_unit_minutes": "Minutes",+ "prune_duration_unit_hours": "Hours",+ "prune_duration_unit_days": "Days",+ "prune_duration_help": "Duration values are stored using Docker-compatible time filters such as 30m, 24h, or 168h.",+ "prune_duration_placeholder": "24",+ "prune_images_dialog_description": "Choose how aggressively Arcane should prune unused Docker images.","auto_update_select_containers": "Select containers...","auto_update_containers_excluded_one": "1 container excluded","auto_update_containers_excluded_many": "{count} containers excluded",@@ -622,7 +641,7 @@"images_prune_failed": "Failed to Prune Images","images_pruned_success": "Images Pruned Successfully","images_prune_confirm_title": "Prune Unused Images",- "images_prune_confirm_description": "Removes unused Docker images (prune mode: {mode}). This frees disk space and cannot be undone. Images referenced by any container will not be removed.",+ "images_prune_confirm_description": "Remove unused Docker images to reclaim disk space. Images referenced by any container will not be removed.","images_prune_action": "Prune Images","images_update_check_completed": "Update check completed","images_update_check_failed": "Failed to check for updates",@@ -1941,6 +1960,7 @@"prune_volumes_guidance": "Only enable this if you are certain no important data resides in unused volumes.","prune_volumes_warning_title": "Warning: Pruning Volumes","prune_volumes_warning_description": "Pruning volumes permanently deletes data. Ensure you have backups if necessary.",+ "prune_volumes_warning_description_all": "Pruning all unused volumes also includes named volumes and permanently deletes their data. Double-check that no shared or long-lived data depends on them before continuing.","prune_button": "Prune Selected ({count})","_comment_form_network": "=== FORM - CREATE NETWORK ===","create_network_title": "Create New Network",diff --git a/frontend/src/lib/components/dialogs/prune-confirmation-dialog-content.svelte b/frontend/src/lib/components/dialogs/prune-confirmation-dialog-content.sveltenew file mode 100644index 000000000..36a3ea754--- /dev/null+++ b/frontend/src/lib/components/dialogs/prune-confirmation-dialog-content.svelte@@ -0,0 +1,180 @@+<script lang="ts">+ import { ArcaneButton } from '$lib/components/arcane-button/index.js';+ import PruneModeCard from '$lib/components/prune/prune-mode-card.svelte';+ import { m } from '$lib/paraglide/messages';+ import type { SystemPruneRequest } from '$lib/types/prune.type';+ import type { Settings } from '$lib/types/settings.type';++ interface Props {+ defaults?: Settings | null;+ isPruning?: boolean;+ onConfirm?: (request: SystemPruneRequest) => void;+ onCancel?: () => void;+ }++ let { defaults = null, isPruning = false, onConfirm = () => {}, onCancel = () => {} }: Props = $props();++ function getInitialSelectionInternal() {+ return {+ containerMode: defaults?.pruneContainerMode ?? 'stopped',+ containerUntil: defaults?.pruneContainerUntil ?? '',+ imageMode: defaults?.pruneImageMode ?? 'dangling',+ imageUntil: defaults?.pruneImageUntil ?? '',+ networkMode: defaults?.pruneNetworkMode ?? 'unused',+ networkUntil: defaults?.pruneNetworkUntil ?? '',+ volumeMode: defaults?.pruneVolumeMode ?? 'none',+ buildCacheMode: defaults?.pruneBuildCacheMode ?? 'none',+ buildCacheUntil: defaults?.pruneBuildCacheUntil ?? ''+ } as const;+ }++ const initialSelectionInternal = getInitialSelectionInternal();++ let containerMode = $state<'none' | 'stopped' | 'olderThan'>(initialSelectionInternal.containerMode);+ let containerUntil = $state(initialSelectionInternal.containerUntil);+ let imageMode = $state<'none' | 'dangling' | 'all' | 'olderThan'>(initialSelectionInternal.imageMode);+ let imageUntil = $state(initialSelectionInternal.imageUntil);+ let networkMode = $state<'none' | 'unused' | 'olderThan'>(initialSelectionInternal.networkMode);+ let networkUntil = $state(initialSelectionInternal.networkUntil);+ let volumeMode = $state<'none' | 'anonymous' | 'all'>(initialSelectionInternal.volumeMode);+ let buildCacheMode = $state<'none' | 'unused' | 'all' | 'olderThan'>(initialSelectionInternal.buildCacheMode);+ let buildCacheUntil = $state(initialSelectionInternal.buildCacheUntil);++ const containerModes = [+ { value: 'none', label: m.prune_mode_none() },+ { value: 'stopped', label: m.prune_stopped_containers() },+ { value: 'olderThan', label: m.prune_mode_older_than() }+ ];+ const imageModes = [+ { value: 'none', label: m.prune_mode_none() },+ { value: 'dangling', label: m.prune_images_mode_dangling() },+ { value: 'all', label: m.prune_images_mode_all() },+ { value: 'olderThan', label: m.prune_mode_older_than() }+ ];+ const networkModes = [+ { value: 'none', label: m.prune_mode_none() },+ { value: 'unused', label: m.prune_unused_networks() },+ { value: 'olderThan', label: m.prune_mode_older_than() }+ ];+ const volumeModes = [+ { value: 'none', label: m.prune_mode_none() },+ { value: 'anonymous', label: m.prune_volumes_mode_anonymous(), destructive: true },+ { value: 'all', label: m.prune_volumes_mode_all(), destructive: true }+ ];+ const buildCacheModes = [+ { value: 'none', label: m.prune_mode_none() },+ { value: 'unused', label: m.prune_build_cache_mode_unused() },+ { value: 'all', label: m.prune_build_cache_mode_all() },+ { value: 'olderThan', label: m.prune_mode_older_than() }+ ];++ function buildPruneRequestInternal(): SystemPruneRequest {+ const request: SystemPruneRequest = {};+ if (containerMode !== 'none') {+ request.containers = {+ mode: containerMode,+ ...(containerMode === 'olderThan' ? { until: containerUntil } : {})+ };+ }+ if (imageMode !== 'none') {+ request.images = {+ mode: imageMode,+ ...(imageMode === 'olderThan' ? { until: imageUntil } : {})+ };+ }+ if (networkMode !== 'none') {+ request.networks = {+ mode: networkMode,+ ...(networkMode === 'olderThan' ? { until: networkUntil } : {})+ };+ }+ if (volumeMode !== 'none') {+ request.volumes = { mode: volumeMode };+ }+ if (buildCacheMode !== 'none') {+ request.buildCache = {+ mode: buildCacheMode,+ ...(buildCacheMode === 'olderThan' ? { until: buildCacheUntil } : {})+ };+ }+ return request;+ }++ let selectedCountInternal = $derived(Object.keys(buildPruneRequestInternal()).length);++ function handleConfirmInternal() {+ const pruneRequest = buildPruneRequestInternal();+ if (Object.keys(pruneRequest).length > 0 && !isPruning) {+ onConfirm(pruneRequest);+ }+ }++ function handleCancelInternal() {+ if (!isPruning) {+ onCancel();+ }+ }+</script>++<div class="space-y-4">+ <div class="grid gap-2 md:grid-cols-2">+ <PruneModeCard+ title={m.prune_containers_label()}+ description={m.scheduled_prune_containers_description()}+ modeOptions={containerModes}+ bind:value={containerMode}+ bind:untilValue={containerUntil}+ disabled={isPruning}+ />+ <PruneModeCard+ title={m.prune_images_label()}+ description={m.prune_images_dialog_description()}+ modeOptions={imageModes}+ bind:value={imageMode}+ bind:untilValue={imageUntil}+ disabled={isPruning}+ />+ <PruneModeCard+ title={m.prune_networks_label()}+ description={m.scheduled_prune_networks_description()}+ modeOptions={networkModes}+ bind:value={networkMode}+ bind:untilValue={networkUntil}+ disabled={isPruning}+ />+ <PruneModeCard+ title={m.prune_volumes_label()}+ description={m.prune_volumes_guidance()}+ modeOptions={volumeModes}+ bind:value={volumeMode}+ disabled={isPruning}+ warningTitle={m.prune_volumes_warning_title()}+ warningDescription={volumeMode === 'all'+ ? m.prune_volumes_warning_description_all()+ : m.prune_volumes_warning_description()}+ />+ <div class="md:col-span-2">+ <PruneModeCard+ title={m.prune_build_cache_label()}+ description={m.scheduled_prune_build_cache_description()}+ modeOptions={buildCacheModes}+ bind:value={buildCacheMode}+ bind:untilValue={buildCacheUntil}+ disabled={isPruning}+ />+ </div>+ </div>++ <div class="grid grid-cols-2 gap-3">+ <ArcaneButton action="cancel" onclick={handleCancelInternal} disabled={isPruning} class="w-full" />+ <ArcaneButton+ action="remove"+ onclick={handleConfirmInternal}+ disabled={selectedCountInternal === 0 || isPruning}+ loading={isPruning}+ customLabel={m.prune_button({ count: selectedCountInternal })}+ loadingLabel={m.common_action_pruning()}+ class="w-full"+ />+ </div>+</div>diff --git a/frontend/src/lib/components/dialogs/prune-confirmation-dialog.svelte b/frontend/src/lib/components/dialogs/prune-confirmation-dialog.svelteindex 79338fa25..624582597 100644--- a/frontend/src/lib/components/dialogs/prune-confirmation-dialog.svelte+++ b/frontend/src/lib/components/dialogs/prune-confirmation-dialog.svelte@@ -1,53 +1,21 @@<script lang="ts">+ import PruneConfirmationDialogContent from '$lib/components/dialogs/prune-confirmation-dialog-content.svelte';import { ResponsiveDialog } from '$lib/components/ui/responsive-dialog/index.js';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import * as Checkbox from '$lib/components/ui/checkbox/index.js';- import { Label } from '$lib/components/ui/label/index.js';- import * as Alert from '$lib/components/ui/alert/index.js';import { m } from '$lib/paraglide/messages';- import { AlertIcon } from '$lib/icons';-- type PruneType = 'containers' | 'images' | 'networks' | 'volumes' | 'buildCache';+ import type { SystemPruneRequest } from '$lib/types/prune.type';+ import type { Settings } from '$lib/types/settings.type';interface Props {- open?: boolean;+ open: boolean;isPruning?: boolean;- imagePruneMode?: 'dangling' | 'all';- onConfirm?: (selectedTypes: PruneType[]) => void;+ defaults?: Settings | null;+ onConfirm?: (request: SystemPruneRequest) => void;onCancel?: () => void;}- let {- open = $bindable(),- isPruning = false,- imagePruneMode = 'dangling',- onConfirm = () => {},- onCancel = () => {}- }: Props = $props();-- let pruneContainers = $state(true);- let pruneImages = $state(true);- let pruneNetworks = $state(true);- let pruneVolumes = $state(false);- let pruneBuildCache = $state(false);-- const selectedTypes = $derived.by(() => {- const types: PruneType[] = [];- if (pruneContainers) types.push('containers');- if (pruneImages) types.push('images');- if (pruneNetworks) types.push('networks');- if (pruneVolumes) types.push('volumes');- if (pruneBuildCache) types.push('buildCache');- return types;- });-- function handleConfirm() {- if (selectedTypes.length > 0 && !isPruning) {- onConfirm(selectedTypes);- }- }+ let { open = $bindable(), isPruning = false, defaults = null, onConfirm = () => {}, onCancel = () => {} }: Props = $props();- function handleCancel() {+ function handleCancelInternal() {if (!isPruning) {onCancel();}@@ -56,82 +24,12 @@<ResponsiveDialog{open}- onOpenChange={(isOpen) => !isOpen && handleCancel()}+ onOpenChange={(isOpen) => !isOpen && handleCancelInternal()}title={m.prune_confirm_system_title()}description={m.prune_confirm_description()}- contentClass="sm:max-w-[450px]"+ contentClass="sm:max-w-[860px]">- {#snippet children()}- <div class="grid gap-4">- <div class="flex items-center space-x-3">- <Checkbox.Root id="prune-containers" bind:checked={pruneContainers} disabled={isPruning} />- <Label- for="prune-containers"- class="text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70"- >- {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- for="prune-images"- class="text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70"- >- {m.prune_unused_images()} ({imagePruneMode === 'dangling' ? m.prune_images_mode_dangling() : m.prune_images_mode_all()})- </Label>- </div>-- <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 leading-none font-medium 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} />- <Label- for="prune-networks"- class="text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70"- >- {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">- <Label for="prune-volumes" class="text-sm font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70">- {m.prune_unused_volumes()} <span class="text-destructive">{m.prune_potentially_destructive()}</span>- </Label>- <p class="text-muted-foreground text-xs">{m.prune_volumes_guidance()}</p>- </div>- </div>-- {#if pruneVolumes}- <Alert.Root variant="destructive" class="mt-2">- <AlertIcon class="size-4" />- <Alert.Title>{m.prune_volumes_warning_title()}</Alert.Title>- <Alert.Description>{m.prune_volumes_warning_description()}</Alert.Description>- </Alert.Root>- {/if}- </div>- {/snippet}-- {#snippet footer()}- <ArcaneButton action="cancel" onclick={handleCancel} disabled={isPruning} />- <ArcaneButton- action="remove"- onclick={handleConfirm}- disabled={selectedTypes.length === 0 || isPruning}- loading={isPruning}- customLabel={m.prune_button({ count: selectedTypes.length })}- loadingLabel={m.common_action_pruning()}- />- {/snippet}+ {#if open}+ <PruneConfirmationDialogContent {defaults} {isPruning} {onConfirm} onCancel={handleCancelInternal} />+ {/if}</ResponsiveDialog>diff --git a/frontend/src/lib/components/prune/prune-mode-card.svelte b/frontend/src/lib/components/prune/prune-mode-card.sveltenew file mode 100644index 000000000..0c28d9326--- /dev/null+++ b/frontend/src/lib/components/prune/prune-mode-card.svelte@@ -0,0 +1,189 @@+<script lang="ts">+ import { Input } from '$lib/components/ui/input/index.js';+ import * as Tabs from '$lib/components/ui/tabs/index.js';+ import { cn } from '$lib/utils.js';+ import { m } from '$lib/paraglide/messages';++ export type PruneModeOption = {+ value: string;+ label: string;+ destructive?: boolean;+ };++ type DurationUnit = 'minutes' | 'hours' | 'days';++ interface Props {+ title: string;+ description: string;+ modeOptions: PruneModeOption[];+ value?: string;+ untilValue?: string;+ disabled?: boolean;+ olderThanMode?: string;+ warningTitle?: string;+ warningDescription?: string;+ }++ let {+ title,+ description,+ modeOptions,+ value = $bindable<string>(),+ untilValue = $bindable(''),+ disabled = false,+ olderThanMode = 'olderThan',+ warningTitle,+ warningDescription+ }: Props = $props();++ const defaultDurationAmountInternal = '24';+ const defaultDurationUnitInternal: DurationUnit = 'hours';+ const durationUnitOptionsInternal: { value: DurationUnit; label: string }[] = [+ { value: 'minutes', label: m.prune_duration_unit_minutes() },+ { value: 'hours', label: m.prune_duration_unit_hours() },+ { value: 'days', label: m.prune_duration_unit_days() }+ ];++ function hasOlderThanInternal(): boolean {+ return modeOptions.some((option) => option.value === olderThanMode);+ }++ function getSelectedOptionInternal(): PruneModeOption | undefined {+ return modeOptions.find((option) => option.value === value);+ }++ let parsedDurationInternal = $derived.by(() => parsePruneDurationInternal(untilValue));+ let durationAmountInternal = $derived(parsedDurationInternal.amount);+ let durationUnitInternal = $derived(parsedDurationInternal.unit);++ function handleModeChange(nextMode: string) {+ if (disabled) return;+ value = nextMode;+ if (nextMode === olderThanMode && !untilValue) {+ untilValue = serializePruneDurationInternal(defaultDurationAmountInternal, defaultDurationUnitInternal);+ }+ }++ function updateDurationAmountInternal(nextAmount: string) {+ untilValue = serializePruneDurationInternal(nextAmount, durationUnitInternal);+ }++ function updateDurationUnitInternal(nextUnit: DurationUnit) {+ untilValue = serializePruneDurationInternal(durationAmountInternal, nextUnit);+ }++ function handleDurationAmountInputInternal(event: Event) {+ updateDurationAmountInternal((event.currentTarget as HTMLInputElement).value);+ }++ function handleDurationUnitChangeInternal(event: Event) {+ updateDurationUnitInternal((event.currentTarget as HTMLSelectElement).value as DurationUnit);+ }++ function parsePruneDurationInternal(valueToParse: string): { amount: string; unit: DurationUnit } {+ const trimmed = valueToParse.trim();+ if (!trimmed) {+ return {+ amount: defaultDurationAmountInternal,+ unit: defaultDurationUnitInternal+ };+ }++ if (trimmed.endsWith('m')) {+ return {+ amount: trimmed.slice(0, -1) || defaultDurationAmountInternal,+ unit: 'minutes'+ };+ }++ if (trimmed.endsWith('h')) {+ const rawHours = Number(trimmed.slice(0, -1));+ if (Number.isFinite(rawHours) && rawHours > 0 && rawHours % 24 === 0) {+ return {+ amount: String(rawHours / 24),+ unit: 'days'+ };+ }++ return {+ amount: trimmed.slice(0, -1) || defaultDurationAmountInternal,+ unit: 'hours'+ };+ }++ return {+ amount: defaultDurationAmountInternal,+ unit: defaultDurationUnitInternal+ };+ }++ function serializePruneDurationInternal(amount: string, unit: DurationUnit): string {+ const parsedAmount = Math.max(1, Number(amount) || 1);+ switch (unit) {+ case 'minutes':+ return `${parsedAmount}m`;+ case 'days':+ return `${parsedAmount * 24}h`;+ default:+ return `${parsedAmount}h`;+ }+ }+</script>++<div class="bg-muted/20 ring-border/20 flex h-full flex-col gap-2.5 rounded-lg p-3 ring-1">+ <div class="space-y-0.5">+ <p class="text-xs font-medium">{title}</p>+ <p class="text-muted-foreground text-[11px] leading-tight">{description}</p>+ </div>++ <Tabs.Root {value} onValueChange={handleModeChange}>+ <Tabs.List class="h-8 w-full">+ {#each modeOptions as option (option.value)}+ <Tabs.Trigger+ value={option.value}+ {disabled}+ class={cn(+ 'h-6 flex-1 text-xs',+ option.destructive && value === option.value && 'bg-destructive/15 text-destructive hover:bg-destructive/10 shadow-sm'+ )}+ >+ {option.label}+ </Tabs.Trigger>+ {/each}+ </Tabs.List>+ </Tabs.Root>++ {#if hasOlderThanInternal() && value === olderThanMode}+ <div class="grid gap-1.5 sm:grid-cols-[minmax(0,1fr)_auto]">+ <Input+ type="number"+ min="1"+ value={durationAmountInternal}+ oninput={handleDurationAmountInputInternal}+ {disabled}+ class="h-8 text-xs"+ placeholder={m.prune_duration_placeholder()}+ />+ <select+ class="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring h-8 rounded-md border px-2.5 py-1 text-xs focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"+ value={durationUnitInternal}+ onchange={handleDurationUnitChangeInternal}+ {disabled}+ >+ {#each durationUnitOptionsInternal as option (option.value)}+ <option value={option.value}>{option.label}</option>+ {/each}+ </select>+ </div>+ <p class="text-muted-foreground text-xs">{m.prune_duration_help()}</p>+ {/if}++ {#if warningDescription && getSelectedOptionInternal()?.destructive}+ <div class="mt-auto rounded-md border border-amber-500/30 bg-amber-500/10 p-2 text-xs text-amber-900 dark:text-amber-200">+ {#if warningTitle}+ <p class="font-medium">{warningTitle}</p>+ {/if}+ <p>{warningDescription}</p>+ </div>+ {/if}+</div>diff --git a/frontend/src/lib/services/image-service.ts b/frontend/src/lib/services/image-service.tsindex a58c7a6b0..3f8e777b2 100644--- a/frontend/src/lib/services/image-service.ts+++ b/frontend/src/lib/services/image-service.ts@@ -3,6 +3,7 @@ import { environmentStore } from '$lib/stores/environment.store.svelte';import type { ImageSummaryDto, ImageUsageCounts, ImageUpdateInfoDto, ImageBuildRecord } from '$lib/types/image.type';import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';import type { AutoUpdateCheck, AutoUpdateResult } from '$lib/types/auto-update.type';+import type { PruneImagesOptions } from '$lib/types/prune.type';import { transformPaginationParams } from '$lib/utils/params.util';export class ImageService extends BaseAPIService {@@ -53,10 +54,9 @@ export class ImageService extends BaseAPIService {await this.handleResponse(this.api.delete(`/environments/${envId}/images/${imageId}`, { params: options }));}- async pruneImages(dangling?: boolean): Promise<any> {+ async pruneImages(options: PruneImagesOptions): Promise<any> {const envId = await environmentStore.getCurrentEnvironmentId();- const body = dangling !== undefined ? { dangling: !!dangling } : {};- return this.handleResponse(this.api.post(`/environments/${envId}/images/prune`, body));+ return this.handleResponse(this.api.post(`/environments/${envId}/images/prune`, options));}async checkImageUpdateByID(imageId: string): Promise<ImageUpdateInfoDto> {diff --git a/frontend/src/lib/services/system-service.ts b/frontend/src/lib/services/system-service.tsindex 9fb9583d4..e3535b31b 100644--- a/frontend/src/lib/services/system-service.ts+++ b/frontend/src/lib/services/system-service.ts@@ -1,17 +1,10 @@import BaseAPIService from './api-service';import { environmentStore } from '$lib/stores/environment.store.svelte';import type { DockerInfo } from '$lib/types/docker-info.type';+import type { SystemPruneRequest } from '$lib/types/prune.type';export class SystemService extends BaseAPIService {- async pruneAll(options: {- containers?: boolean;- images?: boolean;- volumes?: boolean;- networks?: boolean;- buildCache?: boolean;- dangling?: boolean;- until?: string;- }) {+ async pruneAll(options: SystemPruneRequest) {const envId = await environmentStore.getCurrentEnvironmentId();return this.handleResponse(this.api.post(`/environments/${envId}/system/prune`, options));}diff --git a/frontend/src/lib/types/dashboard.type.ts b/frontend/src/lib/types/dashboard.type.tsindex c15ca7b7c..d84e7f131 100644--- a/frontend/src/lib/types/dashboard.type.ts+++ b/frontend/src/lib/types/dashboard.type.ts@@ -16,9 +16,7 @@ export interface DashboardActionItems {items: DashboardActionItem[];}-export interface DashboardSnapshotSettings {- dockerPruneMode: 'all' | 'dangling';-}+export interface DashboardSnapshotSettings {}export interface DashboardSnapshot {containers: Paginated<ContainerSummaryDto, ContainerStatusCounts>;diff --git a/frontend/src/lib/types/prune.type.ts b/frontend/src/lib/types/prune.type.tsnew file mode 100644index 000000000..0262aeb8f--- /dev/null+++ b/frontend/src/lib/types/prune.type.ts@@ -0,0 +1,37 @@+export type PruneContainerMode = 'none' | 'stopped' | 'olderThan';+export type PruneImageMode = 'none' | 'dangling' | 'all' | 'olderThan';+export type PruneVolumeMode = 'none' | 'anonymous' | 'all';+export type PruneNetworkMode = 'none' | 'unused' | 'olderThan';+export type PruneBuildCacheMode = 'none' | 'unused' | 'all' | 'olderThan';++export interface PruneContainersOptions {+ mode: Exclude<PruneContainerMode, 'none'>;+ until?: string;+}++export interface PruneImagesOptions {+ mode: Exclude<PruneImageMode, 'none'>;+ until?: string;+}++export interface PruneVolumesOptions {+ mode: Exclude<PruneVolumeMode, 'none'>;+}++export interface PruneNetworksOptions {+ mode: Exclude<PruneNetworkMode, 'none'>;+ until?: string;+}++export interface PruneBuildCacheOptions {+ mode: Exclude<PruneBuildCacheMode, 'none'>;+ until?: string;+}++export interface SystemPruneRequest {+ containers?: PruneContainersOptions;+ images?: PruneImagesOptions;+ volumes?: PruneVolumesOptions;+ networks?: PruneNetworksOptions;+ buildCache?: PruneBuildCacheOptions;+}diff --git a/frontend/src/lib/types/settings.type.ts b/frontend/src/lib/types/settings.type.tsindex 7bd165914..5c59d7b36 100644--- a/frontend/src/lib/types/settings.type.ts+++ b/frontend/src/lib/types/settings.type.ts@@ -13,7 +13,6 @@ export type Settings = {pollingEnabled: boolean;pollingInterval: number;environmentHealthInterval: number;- dockerPruneMode: 'all' | 'dangling';defaultDeployPullPolicy: 'missing' | 'always' | 'never';scheduledPruneEnabled?: boolean;scheduledPruneInterval?: number;@@ -22,6 +21,15 @@ export type Settings = {scheduledPruneVolumes?: boolean;scheduledPruneNetworks?: boolean;scheduledPruneBuildCache?: boolean;+ pruneContainerMode?: 'none' | 'stopped' | 'olderThan';+ pruneContainerUntil?: string;+ pruneImageMode?: 'none' | 'dangling' | 'all' | 'olderThan';+ pruneImageUntil?: string;+ pruneVolumeMode?: 'none' | 'anonymous' | 'all';+ pruneNetworkMode?: 'none' | 'unused' | 'olderThan';+ pruneNetworkUntil?: string;+ pruneBuildCacheMode?: 'none' | 'unused' | 'all' | 'olderThan';+ pruneBuildCacheUntil?: string;vulnerabilityScanEnabled?: boolean;vulnerabilityScanInterval?: number;autoHealEnabled?: boolean;diff --git a/frontend/src/routes/(app)/dashboard/+page.svelte b/frontend/src/routes/(app)/dashboard/+page.svelteindex c23ec7ab6..3484ec52a 100644--- a/frontend/src/routes/(app)/dashboard/+page.svelte+++ b/frontend/src/routes/(app)/dashboard/+page.svelte@@ -25,6 +25,7 @@import { systemService } from '$lib/services/system-service';import bytes from '$lib/utils/bytes';import type { DockerInfo } from '$lib/types/docker-info.type';+ import type { SystemPruneRequest } from '$lib/types/prune.type';import {CpuIcon,MemoryStickIcon,@@ -43,10 +44,10 @@let { data }: { data: PageData } = $props();let containers = $derived(data.dashboard.containers);let images = $derived(data.dashboard.images);+ let settings = $derived(data.settings);let containerStatusCounts = $derived(data.dashboard.containers.counts ?? { runningContainers: 0, stoppedContainers: 0, totalContainers: 0 });- let settings = $derived(data.dashboard.settings);let imageUsageCounts = $derived(data.dashboard.imageUsageCounts);let dashboardActionItems = $derived(data.dashboard.actionItems);let debugAllGood = $derived(data.debugAllGood ?? false);@@ -353,19 +354,11 @@});}- async function confirmPrune(selectedTypes: PruneType[]) {+ async function confirmPrune(pruneRequest: SystemPruneRequest) {+ const selectedTypes = Object.keys(pruneRequest) as PruneType[];if (isLoading.pruning || selectedTypes.length === 0) return;isLoading.pruning = true;- const pruneOptions = {- containers: selectedTypes.includes('containers'),- images: selectedTypes.includes('images'),- volumes: selectedTypes.includes('volumes'),- networks: selectedTypes.includes('networks'),- buildCache: selectedTypes.includes('buildCache'),- dangling: settings?.dockerPruneMode === 'dangling'- };-const typeLabels: Record<PruneType, string> = {containers: m.prune_stopped_containers(),images: m.prune_unused_images(),@@ -376,7 +369,7 @@const typesString = selectedTypes.map((t) => typeLabels[t]).join(', ');handleApiResultWithCallbacks({- result: await tryCatch(systemService.pruneAll(pruneOptions)),+ result: await tryCatch(systemService.pruneAll(pruneRequest)),message: m.dashboard_prune_failed({ types: typesString }),setLoadingState: (value) => (isLoading.pruning = value),onSuccess: async () => {@@ -614,8 +607,8 @@<PruneConfirmationDialogbind:open={isPruneDialogOpen}+ defaults={settings}isPruning={isLoading.pruning}- imagePruneMode={(settings?.dockerPruneMode as 'dangling' | 'all') || 'dangling'}onConfirm={confirmPrune}onCancel={() => (isPruneDialogOpen = false)}/>diff --git a/frontend/src/routes/(app)/dashboard/+page.ts b/frontend/src/routes/(app)/dashboard/+page.tsindex 1e624f3c4..bb51497ee 100644--- a/frontend/src/routes/(app)/dashboard/+page.ts+++ b/frontend/src/routes/(app)/dashboard/+page.ts@@ -1,4 +1,5 @@import { dashboardService } from '$lib/services/dashboard-service';+import { settingsService } from '$lib/services/settings-service';import { environmentStore } from '$lib/stores/environment.store.svelte';import { queryKeys } from '$lib/query/query-keys';import { throwPageLoadError } from '$lib/utils/page-load-error.util';@@ -10,13 +11,20 @@ export const load: PageLoad = async ({ parent, url }) => {const debugAllGood = url.searchParams.get('debugAllGood') === 'true';try {- const dashboard = await queryClient.fetchQuery({- queryKey: queryKeys.dashboard.snapshot(envId, debugAllGood),- queryFn: () => dashboardService.getDashboardForEnvironment(envId, { debugAllGood })- });+ const [dashboard, settings] = await Promise.all([+ queryClient.fetchQuery({+ queryKey: queryKeys.dashboard.snapshot(envId, debugAllGood),+ queryFn: () => dashboardService.getDashboardForEnvironment(envId, { debugAllGood })+ }),+ queryClient.fetchQuery({+ queryKey: queryKeys.settings.byEnvironment(envId),+ queryFn: () => settingsService.getSettingsForEnvironmentMerged(envId)+ })+ ]);return {dashboard,+ settings,debugAllGood};} catch (err) {diff --git a/frontend/src/routes/(app)/environments/[id]/+page.svelte b/frontend/src/routes/(app)/environments/[id]/+page.svelteindex 05b73f028..315ea477c 100644--- a/frontend/src/routes/(app)/environments/[id]/+page.svelte+++ b/frontend/src/routes/(app)/environments/[id]/+page.svelte@@ -150,7 +150,6 @@autoUpdate: z.boolean(),autoInjectEnv: z.boolean(),followProjectSymlinks: z.boolean(),- dockerPruneMode: z.enum(['all', 'dangling']),defaultDeployPullPolicy: z.enum(['missing', 'always', 'never']),defaultShell: z.string(),projectsDirectory: z.string(),@@ -162,11 +161,15 @@gitSyncMaxBinarySizeMb: z.coerce.number().int().nonnegative(),baseServerUrl: z.string(),scheduledPruneEnabled: z.boolean(),- scheduledPruneContainers: z.boolean(),- scheduledPruneImages: z.boolean(),- scheduledPruneVolumes: z.boolean(),- scheduledPruneNetworks: z.boolean(),- scheduledPruneBuildCache: z.boolean(),+ pruneContainerMode: z.enum(['none', 'stopped', 'olderThan']),+ pruneContainerUntil: z.string(),+ pruneImageMode: z.enum(['none', 'dangling', 'all', 'olderThan']),+ pruneImageUntil: z.string(),+ pruneVolumeMode: z.enum(['none', 'anonymous', 'all']),+ pruneNetworkMode: z.enum(['none', 'unused', 'olderThan']),+ pruneNetworkUntil: z.string(),+ pruneBuildCacheMode: z.enum(['none', 'unused', 'all', 'olderThan']),+ pruneBuildCacheUntil: z.string(),vulnerabilityScanEnabled: z.boolean(),trivyImage: z.string(),trivyNetwork: z.string(),@@ -193,7 +196,6 @@autoUpdate: settings?.autoUpdate ?? false,autoInjectEnv: settings?.autoInjectEnv ?? false,followProjectSymlinks: settings?.followProjectSymlinks ?? false,- dockerPruneMode: (settings?.dockerPruneMode as 'all' | 'dangling') || 'dangling',defaultDeployPullPolicy: (settings?.defaultDeployPullPolicy as 'missing' | 'always' | 'never') || 'missing',defaultShell: settings?.defaultShell || '/bin/sh',projectsDirectory: settings?.projectsDirectory || '/app/data/projects',@@ -205,11 +207,15 @@gitSyncMaxBinarySizeMb: settings?.gitSyncMaxBinarySizeMb ?? 10,baseServerUrl: settings?.baseServerUrl || 'http://localhost',scheduledPruneEnabled: settings?.scheduledPruneEnabled ?? false,- scheduledPruneContainers: settings?.scheduledPruneContainers ?? true,- scheduledPruneImages: settings?.scheduledPruneImages ?? true,- scheduledPruneVolumes: settings?.scheduledPruneVolumes ?? false,- scheduledPruneNetworks: settings?.scheduledPruneNetworks ?? true,- scheduledPruneBuildCache: settings?.scheduledPruneBuildCache ?? false,+ pruneContainerMode: settings?.pruneContainerMode ?? 'stopped',+ pruneContainerUntil: settings?.pruneContainerUntil ?? '',+ pruneImageMode: settings?.pruneImageMode ?? 'dangling',+ pruneImageUntil: settings?.pruneImageUntil ?? '',+ pruneVolumeMode: settings?.pruneVolumeMode ?? 'none',+ pruneNetworkMode: settings?.pruneNetworkMode ?? 'unused',+ pruneNetworkUntil: settings?.pruneNetworkUntil ?? '',+ pruneBuildCacheMode: settings?.pruneBuildCacheMode ?? 'none',+ pruneBuildCacheUntil: settings?.pruneBuildCacheUntil ?? '',vulnerabilityScanEnabled: settings?.vulnerabilityScanEnabled ?? false,trivyImage: settings?.trivyImage || '',trivyNetwork: settings?.trivyNetwork || '',@@ -243,7 +249,6 @@autoUpdate: formData.autoUpdate,autoInjectEnv: formData.autoInjectEnv,followProjectSymlinks: formData.followProjectSymlinks,- dockerPruneMode: formData.dockerPruneMode,defaultDeployPullPolicy: formData.defaultDeployPullPolicy,defaultShell: formData.defaultShell,projectsDirectory: formData.projectsDirectory,@@ -255,11 +260,15 @@gitSyncMaxBinarySizeMb: formData.gitSyncMaxBinarySizeMb,baseServerUrl: formData.baseServerUrl,scheduledPruneEnabled: formData.scheduledPruneEnabled,- scheduledPruneContainers: formData.scheduledPruneContainers,- scheduledPruneImages: formData.scheduledPruneImages,- scheduledPruneVolumes: formData.scheduledPruneVolumes,- scheduledPruneNetworks: formData.scheduledPruneNetworks,- scheduledPruneBuildCache: formData.scheduledPruneBuildCache,+ pruneContainerMode: formData.pruneContainerMode,+ pruneContainerUntil: formData.pruneContainerUntil,+ pruneImageMode: formData.pruneImageMode,+ pruneImageUntil: formData.pruneImageUntil,+ pruneVolumeMode: formData.pruneVolumeMode,+ pruneNetworkMode: formData.pruneNetworkMode,+ pruneNetworkUntil: formData.pruneNetworkUntil,+ pruneBuildCacheMode: formData.pruneBuildCacheMode,+ pruneBuildCacheUntil: formData.pruneBuildCacheUntil,vulnerabilityScanEnabled: formData.vulnerabilityScanEnabled,trivyImage: formData.trivyImage,trivyNetwork: formData.trivyNetwork,@@ -304,15 +313,6 @@}));- const pruneModeOptions = [- { value: 'all', label: m.docker_prune_all(), description: m.docker_prune_all_description() },- { value: 'dangling', label: m.docker_prune_dangling(), description: m.docker_prune_dangling_description() }- ];-- let pruneModeDescription = $derived(- pruneModeOptions.find((o) => o.value === $formInputs.dockerPruneMode.value)?.description ?? m.docker_prune_mode_description()- );-const shellOptions = [{ value: '/bin/sh', label: '/bin/sh', description: m.docker_shell_sh_description() },{ value: '/bin/bash', label: '/bin/bash', description: m.docker_shell_bash_description() },@@ -327,7 +327,7 @@function handleShellSelectChange(value: string) {if (value !== 'custom') {- $formInputs.defaultShell.value = value;+ formInputs.defaultShell.value = value;}}@@ -406,7 +406,7 @@if (isTestingConnection) return;try {isTestingConnection = true;- const customUrl = $formInputs.apiUrl.value !== environment.apiUrl ? $formInputs.apiUrl.value : undefined;+ const customUrl = formInputs.apiUrl.value !== environment.apiUrl ? formInputs.apiUrl.value : undefined;const result = await environmentManagementService.testConnection(environment.id, customUrl);const nextStatus = result.status as EnvironmentStatus;@@ -581,14 +581,7 @@</Tabs.Content><Tabs.Content value="docker">- <DockerTab- {formInputs}- {shellSelectValue}- {handleShellSelectChange}- {shellOptions}- {pruneModeDescription}- {pruneModeOptions}- />+ <DockerTab {formInputs} {shellSelectValue} {handleShellSelectChange} {shellOptions} /></Tabs.Content><Tabs.Content value="security">diff --git a/frontend/src/routes/(app)/environments/[id]/components/DockerTab.svelte b/frontend/src/routes/(app)/environments/[id]/components/DockerTab.svelteindex 11718767e..dd128aba9 100644--- a/frontend/src/routes/(app)/environments/[id]/components/DockerTab.svelte+++ b/frontend/src/routes/(app)/environments/[id]/components/DockerTab.svelte@@ -4,16 +4,45 @@import { Switch } from '$lib/components/ui/switch/index.js';import SelectWithLabel from '$lib/components/form/select-with-label.svelte';import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';+ import PruneModeCard from '$lib/components/prune/prune-mode-card.svelte';import { m } from '$lib/paraglide/messages';import { DockerBrandIcon } from '$lib/icons';- let { formInputs, shellSelectValue, handleShellSelectChange, shellOptions, pruneModeDescription, pruneModeOptions } = $props();+ let { formInputs, shellSelectValue, handleShellSelectChange, shellOptions } = $props();const deployPullPolicyOptions = [{ value: 'missing', label: 'Missing', description: m.deploy_pull_policy_missing() },{ value: 'always', label: m.common_always(), description: m.deploy_pull_policy_always() },{ value: 'never', label: m.common_never(), description: m.deploy_pull_policy_never() }];++ const pruneContainerModes = [+ { value: 'none', label: m.prune_mode_none() },+ { value: 'stopped', label: m.prune_stopped_containers() },+ { value: 'olderThan', label: m.prune_mode_older_than() }+ ];+ const pruneImageModes = [+ { value: 'none', label: m.prune_mode_none() },+ { value: 'dangling', label: m.prune_images_mode_dangling() },+ { value: 'all', label: m.prune_images_mode_all() },+ { value: 'olderThan', label: m.prune_mode_older_than() }+ ];+ const pruneVolumeModes = [+ { value: 'none', label: m.prune_mode_none() },+ { value: 'anonymous', label: m.prune_volumes_mode_anonymous() },+ { value: 'all', label: m.prune_volumes_mode_all(), destructive: true }+ ];+ const pruneNetworkModes = [+ { value: 'none', label: m.prune_mode_none() },+ { value: 'unused', label: m.prune_unused_networks() },+ { value: 'olderThan', label: m.prune_mode_older_than() }+ ];+ const pruneBuildCacheModes = [+ { value: 'none', label: m.prune_mode_none() },+ { value: 'unused', label: m.prune_build_cache_mode_unused() },+ { value: 'all', label: m.prune_build_cache_mode_all() },+ { value: 'olderThan', label: m.prune_mode_older_than() }+ ];</script><Card.Root class="flex flex-col">@@ -27,21 +56,6 @@</Card.Header><Card.Content class="space-y-6 p-4"><div class="grid gap-6 sm:grid-cols-2">- <!-- Prune Mode -->- <div class="space-y-2">- <SelectWithLabel- id="dockerPruneMode"- name="pruneMode"- bind:value={$formInputs.dockerPruneMode.value}- label={m.docker_prune_action_label()}- description={pruneModeDescription}- placeholder={m.docker_prune_placeholder()}- options={pruneModeOptions}- onValueChange={(v) => ($formInputs.dockerPruneMode.value = v as 'all' | 'dangling')}- />- </div>-- <!-- Default Shell --><div class="space-y-2"><SelectWithLabelid="shellSelectValue"@@ -90,5 +104,51 @@</div></div></div>++ <div class="space-y-4 rounded-lg border p-4">+ <div class="space-y-0.5">+ <h3 class="text-sm font-medium">{m.prune_options_title()}</h3>+ <p class="text-muted-foreground text-xs">{m.prune_options_description()}</p>+ </div>++ <div class="grid gap-2 sm:grid-cols-2">+ <PruneModeCard+ title={m.prune_containers_label()}+ description={m.scheduled_prune_containers_description()}+ modeOptions={pruneContainerModes}+ bind:value={$formInputs.pruneContainerMode.value}+ bind:untilValue={$formInputs.pruneContainerUntil.value}+ />+ <PruneModeCard+ title={m.prune_images_label()}+ description={m.scheduled_prune_images_description()}+ modeOptions={pruneImageModes}+ bind:value={$formInputs.pruneImageMode.value}+ bind:untilValue={$formInputs.pruneImageUntil.value}+ />+ <PruneModeCard+ title={m.prune_volumes_label()}+ description={m.scheduled_prune_volumes_description()}+ modeOptions={pruneVolumeModes}+ bind:value={$formInputs.pruneVolumeMode.value}+ warningTitle={m.prune_volumes_warning_title()}+ warningDescription={m.scheduled_prune_volumes_warning()}+ />+ <PruneModeCard+ title={m.prune_networks_label()}+ description={m.scheduled_prune_networks_description()}+ modeOptions={pruneNetworkModes}+ bind:value={$formInputs.pruneNetworkMode.value}+ bind:untilValue={$formInputs.pruneNetworkUntil.value}+ />+ <PruneModeCard+ title={m.prune_build_cache_label()}+ description={m.scheduled_prune_build_cache_description()}+ modeOptions={pruneBuildCacheModes}+ bind:value={$formInputs.pruneBuildCacheMode.value}+ bind:untilValue={$formInputs.pruneBuildCacheUntil.value}+ />+ </div>+ </div></Card.Content></Card.Root>diff --git a/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte b/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelteindex 1ccdf7881..589d9b7e3 100644--- a/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte+++ b/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte@@ -12,7 +12,7 @@import { Input } from '$lib/components/ui/input';import { Checkbox } from '$lib/components/ui/checkbox';import * as ScrollArea from '$lib/components/ui/scroll-area';- import { JobsIcon, AlertIcon } from '$lib/icons';+ import { JobsIcon } from '$lib/icons';import type { JobStatus, JobPrerequisite } from '$lib/types/job-schedule.type';import type { ContainerSummaryDto } from '$lib/types/container.type';@@ -77,7 +77,7 @@case 'gitopsSyncEnabled':return `${envBase}?tab=gitops`;case 'scheduledPruneEnabled':- return undefined;+ return `${envBase}?tab=jobs`;case 'vulnerabilityScanEnabled':return undefined;case 'autoHealEnabled':@@ -412,60 +412,6 @@</div></div>{/if}-- {#if job.id === 'scheduled-prune'}- {#if $formInputs.scheduledPruneEnabled.value}- <div class="border-border/20 space-y-4 border-t pt-3">- <div class="grid gap-3 sm:grid-cols-2">- <div class="bg-muted/20 ring-border/20 flex items-start justify-between rounded-lg p-3 ring-1">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_containers_label()}</Label>- <p class="text-muted-foreground text-xs">{m.scheduled_prune_containers_description()}</p>- </div>- <Switch bind:checked={$formInputs.scheduledPruneContainers.value} />- </div>- <div class="bg-muted/20 ring-border/20 flex items-start justify-between rounded-lg p-3 ring-1">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_images_label()}</Label>- <p class="text-muted-foreground text-xs">{m.scheduled_prune_images_description()}</p>- </div>- <Switch bind:checked={$formInputs.scheduledPruneImages.value} />- </div>- <div class="bg-muted/20 ring-border/20 flex items-start justify-between rounded-lg p-3 ring-1">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_volumes_label()}</Label>- <p class="text-muted-foreground text-xs">{m.scheduled_prune_volumes_description()}</p>- </div>- <Switch bind:checked={$formInputs.scheduledPruneVolumes.value} />- </div>- <div class="bg-muted/20 ring-border/20 flex items-start justify-between rounded-lg p-3 ring-1">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_networks_label()}</Label>- <p class="text-muted-foreground text-xs">{m.scheduled_prune_networks_description()}</p>- </div>- <Switch bind:checked={$formInputs.scheduledPruneNetworks.value} />- </div>- <div class="bg-muted/20 ring-border/20 flex items-start justify-between rounded-lg p-3 ring-1">- <div class="space-y-0.5">- <Label class="text-sm font-medium">{m.scheduled_prune_build_cache_label()}</Label>- <p class="text-muted-foreground text-xs">{m.scheduled_prune_build_cache_description()}</p>- </div>- <Switch bind:checked={$formInputs.scheduledPruneBuildCache.value} />- </div>- </div>- {#if $formInputs.scheduledPruneVolumes.value}- <div- class="flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-amber-900 dark:text-amber-200"- >- <AlertIcon class="mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400" />- <div class="space-y-1 text-sm">- <p class="font-medium">{m.scheduled_prune_volumes_warning()}</p>- </div>- </div>- {/if}- </div>- {/if}- {/if}</JobCard>{/each}</div>diff --git a/frontend/src/routes/(app)/images/+page.svelte b/frontend/src/routes/(app)/images/+page.svelteindex 7ffd8dfc0..c8b310e3e 100644--- a/frontend/src/routes/(app)/images/+page.svelte+++ b/frontend/src/routes/(app)/images/+page.svelte@@ -16,6 +16,7 @@import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';import { CloseIcon, VolumesIcon, LocalFolderComputerIcon, CodeIcon } from '$lib/icons';import { createMutation, createQuery } from '@tanstack/svelte-query';+ import PruneModeCard from '$lib/components/prune/prune-mode-card.svelte';let { data } = $props();@@ -26,6 +27,8 @@let isUploadDialogOpen = $state(false);let isConfirmPruneDialogOpen = $state(false);let uploadedFiles = $state<File[]>([]);+ let imagePruneMode = $state<'dangling' | 'all' | 'olderThan'>('dangling');+ let imagePruneUntil = $state('');const envId = $derived(environmentStore.selected?.id || '0');const imageUsageFallback: ImageUsageCounts = {imagesInuse: 0,@@ -35,7 +38,6 @@};const maxUploadSizeMB = $derived(parseInt(String(data.settings?.maxImageUploadSize || '500'), 10));- const shouldPruneDangling = $derived(data.settings?.dockerPruneMode === 'dangling');const imagesQuery = createQuery(() => ({queryKey: queryKeys.images.list(envId, requestOptions),@@ -51,7 +53,11 @@const pruneImagesMutation = createMutation(() => ({mutationKey: ['images', 'prune', envId],- mutationFn: () => imageService.pruneImages(shouldPruneDangling),+ mutationFn: () =>+ imageService.pruneImages({+ mode: imagePruneMode,+ ...(imagePruneMode === 'olderThan' ? { until: imagePruneUntil } : {})+ }),onSuccess: async () => {toast.success(m.images_pruned_success());await Promise.all([imagesQuery.refetch(), imageUsageCountsQuery.refetch()]);@@ -132,6 +138,12 @@await pruneImagesMutation.mutateAsync();}+ const imagePruneModes = [+ { value: 'dangling', label: m.prune_images_mode_dangling() },+ { value: 'all', label: m.prune_images_mode_all() },+ { value: 'olderThan', label: m.prune_mode_older_than() }+ ];+async function refresh() {await Promise.all([imagesQuery.refetch(), imageUsageCountsQuery.refetch()]);}@@ -273,10 +285,18 @@<Dialog.Content><Dialog.Header><Dialog.Title>{m.images_prune_confirm_title()}</Dialog.Title>- <Dialog.Description- >{m.images_prune_confirm_description({ mode: String(data.settings.dockerPruneMode) })}</Dialog.Description- >+ <Dialog.Description>{m.images_prune_confirm_description()}</Dialog.Description></Dialog.Header>+ <div class="py-4">+ <PruneModeCard+ title={m.prune_images_label()}+ description={m.prune_images_dialog_description()}+ modeOptions={imagePruneModes}+ bind:value={imagePruneMode}+ bind:untilValue={imagePruneUntil}+ disabled={isPruning}+ />+ </div><div class="flex justify-end gap-3 pt-6"><ArcaneButton action="cancel" onclick={() => (isConfirmPruneDialogOpen = false)} disabled={isPruning} /><ArcaneButtondiff --git a/types/dashboard/dashboard.go b/types/dashboard/dashboard.goindex f65860716..b82688659 100644--- a/types/dashboard/dashboard.go+++ b/types/dashboard/dashboard.go@@ -46,12 +46,7 @@ type ActionItems struct {Items []ActionItem `json:"items"`}-type SnapshotSettings struct {- // DockerPruneMode controls whether prune defaults to all or dangling images.- //- // Required: true- DockerPruneMode string `json:"dockerPruneMode"`-}+type SnapshotSettings struct{}type SnapshotContainers struct {// Data is the first dashboard page of container summaries.diff --git a/types/go.mod b/types/go.modindex 14786f732..f423a5e01 100644--- a/types/go.mod+++ b/types/go.mod@@ -7,6 +7,7 @@ require (github.com/docker/go-units v0.5.0github.com/moby/moby/api v1.54.1github.com/moby/moby/client v0.4.0+ github.com/stretchr/testify v1.11.1)require (@@ -38,4 +39,5 @@ require (go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirectgolang.org/x/sync v0.20.0 // indirectgolang.org/x/sys v0.43.0 // indirect+ gopkg.in/yaml.v3 v3.0.1 // indirect)diff --git a/types/go.sum b/types/go.sumindex 1d8f36650..14732496c 100644--- a/types/go.sum+++ b/types/go.sum@@ -29,6 +29,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=+github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=@@ -43,6 +45,7 @@ github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwgithub.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=+github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=@@ -68,6 +71,7 @@ go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPgolang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=diff --git a/types/settings/settings.go b/types/settings/settings.goindex 1ef53ec53..f6851843d 100644--- a/types/settings/settings.go+++ b/types/settings/settings.go@@ -85,6 +85,8 @@ type Update struct {// PruneMode is the Docker prune mode ("all" or "dangling").//+ // Deprecated: Use the granular prune mode settings instead.+ //// Required: falsePruneMode *string `json:"dockerPruneMode,omitempty" binding:"omitempty,oneof=all dangling"`@@ -105,29 +107,84 @@ type Update struct {// ScheduledPruneContainers indicates if stopped containers should be pruned.//+ // Deprecated: Use pruneContainerMode instead.+ //// Required: falseScheduledPruneContainers *string `json:"scheduledPruneContainers,omitempty"`// ScheduledPruneImages indicates if unused images should be pruned.//+ // Deprecated: Use pruneImageMode instead.+ //// Required: falseScheduledPruneImages *string `json:"scheduledPruneImages,omitempty"`// ScheduledPruneVolumes indicates if unused volumes should be pruned.//+ // Deprecated: Use pruneVolumeMode instead.+ //// Required: falseScheduledPruneVolumes *string `json:"scheduledPruneVolumes,omitempty"`// ScheduledPruneNetworks indicates if unused networks should be pruned.//+ // Deprecated: Use pruneNetworkMode instead.+ //// Required: falseScheduledPruneNetworks *string `json:"scheduledPruneNetworks,omitempty"`// ScheduledPruneBuildCache indicates if build cache should be pruned.//+ // Deprecated: Use pruneBuildCacheMode instead.+ //// Required: falseScheduledPruneBuildCache *string `json:"scheduledPruneBuildCache,omitempty"`+ // PruneContainerMode controls how containers are pruned during scheduled prune.+ //+ // Required: false+ PruneContainerMode *string `json:"pruneContainerMode,omitempty" binding:"omitempty,oneof=none stopped olderThan"`++ // PruneContainerUntil is the Docker duration string used when the container prune mode is olderThan.+ //+ // Required: false+ PruneContainerUntil *string `json:"pruneContainerUntil,omitempty"`++ // PruneImageMode controls how images are pruned during scheduled prune.+ //+ // Required: false+ PruneImageMode *string `json:"pruneImageMode,omitempty" binding:"omitempty,oneof=none dangling all olderThan"`++ // PruneImageUntil is the Docker duration string used when the image prune mode is olderThan.+ //+ // Required: false+ PruneImageUntil *string `json:"pruneImageUntil,omitempty"`++ // PruneVolumeMode controls how volumes are pruned during scheduled prune.+ //+ // Required: false+ PruneVolumeMode *string `json:"pruneVolumeMode,omitempty" binding:"omitempty,oneof=none anonymous all"`++ // PruneNetworkMode controls how networks are pruned during scheduled prune.+ //+ // Required: false+ PruneNetworkMode *string `json:"pruneNetworkMode,omitempty" binding:"omitempty,oneof=none unused olderThan"`++ // PruneNetworkUntil is the Docker duration string used when the network prune mode is olderThan.+ //+ // Required: false+ PruneNetworkUntil *string `json:"pruneNetworkUntil,omitempty"`++ // PruneBuildCacheMode controls how build cache is pruned during scheduled prune.+ //+ // Required: false+ PruneBuildCacheMode *string `json:"pruneBuildCacheMode,omitempty" binding:"omitempty,oneof=none unused all olderThan"`++ // PruneBuildCacheUntil is the Docker duration string used when the build cache prune mode is olderThan.+ //+ // Required: false+ PruneBuildCacheUntil *string `json:"pruneBuildCacheUntil,omitempty"`+// VulnerabilityScanEnabled indicates if scheduled vulnerability scanning is enabled.//// Required: falsediff --git a/types/system/prune.go b/types/system/prune.goindex 1449dcf7f..630d8b938 100644--- a/types/system/prune.go+++ b/types/system/prune.go@@ -1,36 +1,242 @@package system+import "encoding/json"++type PruneContainerMode string++const (+ PruneContainerModeNone PruneContainerMode = "none"+ PruneContainerModeStopped PruneContainerMode = "stopped"+ PruneContainerModeOlderThan PruneContainerMode = "olderThan"+)++type PruneImageMode string++const (+ PruneImageModeNone PruneImageMode = "none"+ PruneImageModeDangling PruneImageMode = "dangling"+ PruneImageModeAll PruneImageMode = "all"+ PruneImageModeOlderThan PruneImageMode = "olderThan"+)++type PruneVolumeMode string++const (+ PruneVolumeModeNone PruneVolumeMode = "none"+ PruneVolumeModeAnonymous PruneVolumeMode = "anonymous"+ PruneVolumeModeAll PruneVolumeMode = "all"+)++type PruneNetworkMode string++const (+ PruneNetworkModeNone PruneNetworkMode = "none"+ PruneNetworkModeUnused PruneNetworkMode = "unused"+ PruneNetworkModeOlderThan PruneNetworkMode = "olderThan"+)++type PruneBuildCacheMode string++const (+ PruneBuildCacheModeNone PruneBuildCacheMode = "none"+ PruneBuildCacheModeUnused PruneBuildCacheMode = "unused"+ PruneBuildCacheModeAll PruneBuildCacheMode = "all"+ PruneBuildCacheModeOlderThan PruneBuildCacheMode = "olderThan"+)++type PruneContainersOptions struct {+ Mode PruneContainerMode `json:"mode"`+ Until string `json:"until,omitempty"`+}++type PruneImagesOptions struct {+ Mode PruneImageMode `json:"mode"`+ Until string `json:"until,omitempty"`+}++type PruneVolumesOptions struct {+ Mode PruneVolumeMode `json:"mode"`+}++type PruneNetworksOptions struct {+ Mode PruneNetworkMode `json:"mode"`+ Until string `json:"until,omitempty"`+}++type PruneBuildCacheOptions struct {+ Mode PruneBuildCacheMode `json:"mode"`+ Until string `json:"until,omitempty"`+}+// PruneAllRequest is used to request pruning of Docker system resources.type PruneAllRequest struct {- // Containers indicates if containers should be pruned.- //- // Required: true- Containers bool `json:"containers"`+ Containers *PruneContainersOptions `json:"containers,omitempty"`+ Images *PruneImagesOptions `json:"images,omitempty"`+ Volumes *PruneVolumesOptions `json:"volumes,omitempty"`+ Networks *PruneNetworksOptions `json:"networks,omitempty"`+ BuildCache *PruneBuildCacheOptions `json:"buildCache,omitempty"`+}- // Images indicates if images should be pruned.- //- // Required: true- Images bool `json:"images"`+type pruneAllRequestWireInternal struct {+ Containers json.RawMessage `json:"containers,omitempty"`+ Images json.RawMessage `json:"images,omitempty"`+ Volumes json.RawMessage `json:"volumes,omitempty"`+ Networks json.RawMessage `json:"networks,omitempty"`+ BuildCache json.RawMessage `json:"buildCache,omitempty"`+ Dangling *bool `json:"dangling,omitempty"`+}- // Volumes indicates if volumes should be pruned.- //- // Required: true- Volumes bool `json:"volumes"`+func (r *PruneAllRequest) UnmarshalJSON(data []byte) error {+ var wire pruneAllRequestWireInternal+ if err := json.Unmarshal(data, &wire); err != nil {+ return err+ }- // Networks indicates if networks should be pruned.- //- // Required: true- Networks bool `json:"networks"`+ *r = PruneAllRequest{}- // BuildCache indicates if build cache should be pruned.- //- // Required: true- BuildCache bool `json:"buildCache"`+ containers, err := decodePruneContainersOptionsInternal(wire.Containers)+ if err != nil {+ return err+ }+ r.Containers = containers- // Dangling indicates if only dangling resources should be pruned.- //- // Required: true- Dangling bool `json:"dangling"`+ images, err := decodePruneImagesOptionsInternal(wire.Images, wire.Dangling)+ if err != nil {+ return err+ }+ r.Images = images++ volumes, err := decodePruneVolumesOptionsInternal(wire.Volumes, wire.Dangling)+ if err != nil {+ return err+ }+ r.Volumes = volumes++ networks, err := decodePruneNetworksOptionsInternal(wire.Networks)+ if err != nil {+ return err+ }+ r.Networks = networks++ buildCache, err := decodePruneBuildCacheOptionsInternal(wire.BuildCache, wire.Dangling)+ if err != nil {+ return err+ }+ r.BuildCache = buildCache++ return nil+}++func decodePruneContainersOptionsInternal(raw json.RawMessage) (*PruneContainersOptions, error) {+ if len(raw) == 0 || string(raw) == "null" {+ return nil, nil+ }++ var enabled bool+ if err := json.Unmarshal(raw, &enabled); err == nil {+ if !enabled {+ return nil, nil+ }+ return &PruneContainersOptions{Mode: PruneContainerModeStopped}, nil+ }++ var options PruneContainersOptions+ if err := json.Unmarshal(raw, &options); err != nil {+ return nil, err+ }+ return &options, nil+}++func decodePruneImagesOptionsInternal(raw json.RawMessage, dangling *bool) (*PruneImagesOptions, error) {+ if len(raw) == 0 || string(raw) == "null" {+ return nil, nil+ }++ var enabled bool+ if err := json.Unmarshal(raw, &enabled); err == nil {+ if !enabled {+ return nil, nil+ }+ mode := PruneImageModeDangling+ if dangling != nil && !*dangling {+ mode = PruneImageModeAll+ }+ return &PruneImagesOptions{Mode: mode}, nil+ }++ var options PruneImagesOptions+ if err := json.Unmarshal(raw, &options); err != nil {+ return nil, err+ }+ return &options, nil+}++func decodePruneVolumesOptionsInternal(raw json.RawMessage, dangling *bool) (*PruneVolumesOptions, error) {+ if len(raw) == 0 || string(raw) == "null" {+ return nil, nil+ }++ var enabled bool+ if err := json.Unmarshal(raw, &enabled); err == nil {+ if !enabled {+ return nil, nil+ }+ mode := PruneVolumeModeAnonymous+ if dangling != nil && !*dangling {+ mode = PruneVolumeModeAll+ }+ return &PruneVolumesOptions{Mode: mode}, nil+ }++ var options PruneVolumesOptions+ if err := json.Unmarshal(raw, &options); err != nil {+ return nil, err+ }+ return &options, nil+}++func decodePruneNetworksOptionsInternal(raw json.RawMessage) (*PruneNetworksOptions, error) {+ if len(raw) == 0 || string(raw) == "null" {+ return nil, nil+ }++ var enabled bool+ if err := json.Unmarshal(raw, &enabled); err == nil {+ if !enabled {+ return nil, nil+ }+ return &PruneNetworksOptions{Mode: PruneNetworkModeUnused}, nil+ }++ var options PruneNetworksOptions+ if err := json.Unmarshal(raw, &options); err != nil {+ return nil, err+ }+ return &options, nil+}++func decodePruneBuildCacheOptionsInternal(raw json.RawMessage, dangling *bool) (*PruneBuildCacheOptions, error) {+ if len(raw) == 0 || string(raw) == "null" {+ return nil, nil+ }++ var enabled bool+ if err := json.Unmarshal(raw, &enabled); err == nil {+ if !enabled {+ return nil, nil+ }+ mode := PruneBuildCacheModeUnused+ if dangling != nil && !*dangling {+ mode = PruneBuildCacheModeAll+ }+ return &PruneBuildCacheOptions{Mode: mode}, nil+ }++ var options PruneBuildCacheOptions+ if err := json.Unmarshal(raw, &options); err != nil {+ return nil, err+ }+ return &options, nil}// PruneAllResult is the result of a prune operation on Docker system resources.diff --git a/types/system/prune_test.go b/types/system/prune_test.gonew file mode 100644index 000000000..8dcb5ffe8--- /dev/null+++ b/types/system/prune_test.go@@ -0,0 +1,73 @@+package system++import (+ "encoding/json"+ "testing"++ "github.com/stretchr/testify/require"+)++func TestPruneAllRequestUnmarshalJSON_LegacyDanglingPayload(t *testing.T) {+ var req PruneAllRequest++ err := json.Unmarshal([]byte(`{+ "containers": true,+ "images": true,+ "volumes": true,+ "networks": true,+ "buildCache": true,+ "dangling": true+ }`), &req)+ require.NoError(t, err)++ require.Equal(t, &PruneContainersOptions{Mode: PruneContainerModeStopped}, req.Containers)+ require.Equal(t, &PruneImagesOptions{Mode: PruneImageModeDangling}, req.Images)+ require.Equal(t, &PruneVolumesOptions{Mode: PruneVolumeModeAnonymous}, req.Volumes)+ require.Equal(t, &PruneNetworksOptions{Mode: PruneNetworkModeUnused}, req.Networks)+ require.Equal(t, &PruneBuildCacheOptions{Mode: PruneBuildCacheModeUnused}, req.BuildCache)+}++func TestPruneAllRequestUnmarshalJSON_LegacyAllPayload(t *testing.T) {+ var req PruneAllRequest++ err := json.Unmarshal([]byte(`{+ "containers": true,+ "images": true,+ "volumes": true,+ "networks": true,+ "buildCache": true,+ "dangling": false+ }`), &req)+ require.NoError(t, err)++ require.Equal(t, &PruneContainersOptions{Mode: PruneContainerModeStopped}, req.Containers)+ require.Equal(t, &PruneImagesOptions{Mode: PruneImageModeAll}, req.Images)+ require.Equal(t, &PruneVolumesOptions{Mode: PruneVolumeModeAll}, req.Volumes)+ require.Equal(t, &PruneNetworksOptions{Mode: PruneNetworkModeUnused}, req.Networks)+ require.Equal(t, &PruneBuildCacheOptions{Mode: PruneBuildCacheModeAll}, req.BuildCache)+}++func TestPruneAllRequestUnmarshalJSON_StructuredPayloadPreserved(t *testing.T) {+ var req PruneAllRequest++ err := json.Unmarshal([]byte(`{+ "containers": {"mode": "olderThan", "until": "24h"},+ "images": {"mode": "all"},+ "volumes": {"mode": "anonymous"},+ "networks": {"mode": "none"},+ "buildCache": {"mode": "olderThan", "until": "30m"}+ }`), &req)+ require.NoError(t, err)++ require.Equal(t, &PruneContainersOptions{+ Mode: PruneContainerModeOlderThan,+ Until: "24h",+ }, req.Containers)+ require.Equal(t, &PruneImagesOptions{Mode: PruneImageModeAll}, req.Images)+ require.Equal(t, &PruneVolumesOptions{Mode: PruneVolumeModeAnonymous}, req.Volumes)+ require.Equal(t, &PruneNetworksOptions{Mode: PruneNetworkModeNone}, req.Networks)+ require.Equal(t, &PruneBuildCacheOptions{+ Mode: PruneBuildCacheModeOlderThan,+ Until: "30m",+ }, req.BuildCache)+}