Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: per-container auto-update toggle in detail view (#2178)
Giulio Savini0ab8e0abcd35
diff --git a/backend/internal/huma/handlers/containers.go b/backend/internal/huma/handlers/containers.goindex 1566475c4..6bbbc4e7c 100644--- a/backend/internal/huma/handlers/containers.go+++ b/backend/internal/huma/handlers/containers.go@@ -22,6 +22,7 @@ import (type ContainerHandler struct {containerService *services.ContainerServicedockerService *services.DockerClientService+ settingsService *services.SettingsService}// Paginated response@@ -121,10 +122,23 @@ type DeleteContainerOutput struct {}// RegisterContainers registers container endpoints.-func RegisterContainers(api huma.API, containerSvc *services.ContainerService, dockerSvc *services.DockerClientService) {+type SetAutoUpdateInput struct {+ EnvironmentID string `path:"id" doc:"Environment ID"`+ ContainerID string `path:"containerId" doc:"Container ID"`+ Body struct {+ Enabled bool `json:"enabled" doc:"Whether auto-update is enabled for this container"`+ }+}++type SetAutoUpdateOutput struct {+ Body ContainerActionResponse+}++func RegisterContainers(api huma.API, containerSvc *services.ContainerService, dockerSvc *services.DockerClientService, settingsSvc *services.SettingsService) {h := &ContainerHandler{containerService: containerSvc,dockerService: dockerSvc,+ settingsService: settingsSvc,}huma.Register(api, huma.Operation{@@ -209,6 +223,16 @@ func RegisterContainers(api huma.API, containerSvc *services.ContainerService, dTags: []string{"Containers"},Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},}, h.DeleteContainer)++ huma.Register(api, huma.Operation{+ OperationID: "set-container-auto-update",+ Method: http.MethodPut,+ Path: "/environments/{id}/containers/{containerId}/auto-update",+ Summary: "Set container auto-update",+ Description: "Enable or disable auto-update for a specific container",+ Tags: []string{"Containers", "Updater"},+ Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},+ }, h.SetAutoUpdate)}func (h *ContainerHandler) ListContainers(ctx context.Context, input *ListContainersInput) (*ListContainersOutput, error) {@@ -695,3 +719,32 @@ func (h *ContainerHandler) DeleteContainer(ctx context.Context, input *DeleteCon},}, nil}++func (h *ContainerHandler) SetAutoUpdate(ctx context.Context, input *SetAutoUpdateInput) (*SetAutoUpdateOutput, error) {+ if h.settingsService == nil {+ return nil, huma.Error500InternalServerError("service not available")+ }++ // Resolve container name from ID+ containerName, err := h.containerService.GetContainerNameByID(ctx, input.ContainerID)+ if err != nil {+ return nil, huma.Error404NotFound("container not found")+ }++ excluded := !input.Body.Enabled+ if err := h.settingsService.SetContainerAutoUpdateExclusionInternal(ctx, containerName, excluded); err != nil {+ return nil, huma.Error500InternalServerError("failed to update auto-update setting")+ }++ msg := "Auto-update enabled"+ if excluded {+ msg = "Auto-update disabled"+ }++ return &SetAutoUpdateOutput{+ Body: ContainerActionResponse{+ Success: true,+ Data: base.MessageResponse{Message: msg},+ },+ }, nil+}diff --git a/backend/internal/huma/huma.go b/backend/internal/huma/huma.goindex 8f613e658..4df420842 100644--- a/backend/internal/huma/huma.go+++ b/backend/internal/huma/huma.go@@ -395,7 +395,7 @@ func registerHandlers(api huma.API, svc *Services) {handlers.RegisterSettings(api, settingsSvc, settingsSearchSvc, environmentSvc, cfg)handlers.RegisterJobSchedules(api, jobScheduleSvc, environmentSvc)handlers.RegisterVolumes(api, dockerSvc, volumeSvc)- handlers.RegisterContainers(api, containerSvc, dockerSvc)+ handlers.RegisterContainers(api, containerSvc, dockerSvc, settingsSvc)handlers.RegisterPorts(api, portSvc)handlers.RegisterNetworks(api, networkSvc, dockerSvc)handlers.RegisterSwarm(api, swarmSvc, environmentSvc, eventSvc, cfg)diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.goindex 2c8707eec..f584d877a 100644--- a/backend/internal/services/container_service.go+++ b/backend/internal/services/container_service.go@@ -437,6 +437,15 @@ func (s *ContainerService) GetContainerByID(ctx context.Context, id string) (*coreturn &containerInfo, nil}+// GetContainerNameByID resolves a container's clean name from its Docker ID.+func (s *ContainerService) GetContainerNameByID(ctx context.Context, id string) (string, error) {+ info, err := s.GetContainerByID(ctx, id)+ if err != nil {+ return "", err+ }+ return strings.TrimPrefix(info.Name, "/"), nil+}+func (s *ContainerService) DeleteContainer(ctx context.Context, containerID string, force bool, removeVolumes bool, user models.User) error {dockerClient, err := s.dockerService.GetClient(ctx)if err != nil {diff --git a/backend/internal/services/settings_service.go b/backend/internal/services/settings_service.goindex 994bb4e53..f765d2ef0 100644--- a/backend/internal/services/settings_service.go+++ b/backend/internal/services/settings_service.go@@ -927,6 +927,41 @@ func (s *SettingsService) SetStringSetting(ctx context.Context, key, value strinreturn s.UpdateSetting(ctx, key, value)}+// SetContainerAutoUpdateExclusionInternal adds or removes a container name from+// the autoUpdateExcludedContainers setting. When excluded is true the container+// is added to the list; when false it is removed.+func (s *SettingsService) SetContainerAutoUpdateExclusionInternal(ctx context.Context, containerName string, excluded bool) error {+ raw := s.GetStringSetting(ctx, "autoUpdateExcludedContainers", "")+ existing := make(map[string]struct{})+ var ordered []string+ for part := range strings.SplitSeq(raw, ",") {+ name := strings.TrimSpace(part)+ if name == "" {+ continue+ }+ if _, ok := existing[name]; !ok {+ existing[name] = struct{}{}+ ordered = append(ordered, name)+ }+ }++ if excluded {+ if _, ok := existing[containerName]; !ok {+ ordered = append(ordered, containerName)+ }+ } else {+ filtered := ordered[:0]+ for _, name := range ordered {+ if name != containerName {+ filtered = append(filtered, name)+ }+ }+ ordered = filtered+ }++ return s.SetStringSetting(ctx, "autoUpdateExcludedContainers", strings.Join(ordered, ","))+}+func (s *SettingsService) EnsureEncryptionKey(ctx context.Context) (string, error) {const keyName = "encryptionKey"var key stringdiff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 7d1dfd266..e21b8d8d7 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -215,6 +215,11 @@"auto_update_containers_excluded_many": "{count} containers excluded","auto_update_exclude_description": "Select containers to exclude from automatic updates.","auto_update_excluded_containers": "Excluded Containers",+ "auto_update_title": "Auto-Update",+ "auto_update_enabled_toast": "Auto-update enabled",+ "auto_update_disabled_toast": "Auto-update disabled",+ "auto_update_failed": "Failed to update auto-update setting",+ "auto_update_controlled_by_label": "Controlled by Docker label","auto_heal_excluded_containers": "Excluded Containers","auto_heal_exclude_description": "Select containers to exclude from auto-heal monitoring.","auto_heal_max_restarts_label": "Max Restarts",diff --git a/frontend/src/lib/services/container-service.ts b/frontend/src/lib/services/container-service.tsindex 99c1d0484..7ce1e982d 100644--- a/frontend/src/lib/services/container-service.ts+++ b/frontend/src/lib/services/container-service.ts@@ -101,6 +101,13 @@ export class ContainerService extends BaseAPIService {const envId = await environmentStore.getCurrentEnvironmentId();return this.handleResponse(this.api.post(`/environments/${envId}/containers/${containerId}/redeploy`));}++ async setAutoUpdate(containerId: string, enabled: boolean): Promise<{ success: boolean; data: { message: string } }> {+ const envId = await environmentStore.getCurrentEnvironmentId();+ return this.handleResponse(+ this.api.put(`/environments/${envId}/containers/${containerId}/auto-update`, { enabled })+ );+ }}export const containerService = new ContainerService();diff --git a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte b/frontend/src/routes/(app)/containers/[containerId]/+page.svelteindex 49febb459..0dc6a41a4 100644--- a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte+++ b/frontend/src/routes/(app)/containers/[containerId]/+page.svelte@@ -49,6 +49,30 @@let autoScrollLogs = $state(true);let hasInitialStatsLoaded = $state(false);+ // Auto-update: detect whether the Docker label controls the state (not toggleable via UI)+ function isAutoUpdateLabelControlled(c: ContainerDetailsDto): boolean {+ if (!c?.labels) return false;+ const labelValue = Object.entries(c.labels).find(+ ([k]) => k.toLowerCase() === 'com.getarcaneapp.arcane.updater'+ )?.[1];+ return !!labelValue && ['false', '0', 'no', 'off'].includes(labelValue.trim().toLowerCase());+ }++ function isAutoUpdateEnabled(c: ContainerDetailsDto, settings: any): boolean {+ if (isAutoUpdateLabelControlled(c)) return false;+ const excluded = settings?.autoUpdateExcludedContainers ?? '';+ const containerName = c?.name?.replace(/^\/+/, '') ?? '';+ if (containerName && excluded) {+ const excludedList = excluded.split(',').map((s: string) => s.trim());+ if (excludedList.includes(containerName)) return false;+ }+ return true;+ }++ const autoUpdateLabelControlled = $derived(isAutoUpdateLabelControlled(container));+ let autoUpdateOverride = $state<boolean | null>(null);+ const autoUpdateEnabled = $derived(autoUpdateOverride ?? isAutoUpdateEnabled(container, data?.settings));+const cleanContainerName = (name: string | undefined): string => {if (!name) return m.common_not_found_title({ resource: m.containers_title() });return name.replace(/^\/+/, '');@@ -248,6 +272,9 @@<ContainerOverview{container}{primaryIpAddress}+ {autoUpdateEnabled}+ {autoUpdateLabelControlled}+ onAutoUpdateChange={(enabled) => { autoUpdateOverride = enabled; }}onViewPortMappings={showNetworkTab ? navigateToNetworkPortMappings : undefined}/></Tabs.Content>diff --git a/frontend/src/routes/(app)/containers/components/ContainerOverview.svelte b/frontend/src/routes/(app)/containers/components/ContainerOverview.svelteindex 19c7796ce..0a1c1467e 100644--- a/frontend/src/routes/(app)/containers/components/ContainerOverview.svelte+++ b/frontend/src/routes/(app)/containers/components/ContainerOverview.svelte@@ -1,18 +1,39 @@<script lang="ts">import * as Card from '$lib/components/ui/card';import StatusBadge from '$lib/components/badges/status-badge.svelte';+ import { Switch } from '$lib/components/ui/switch';import { m } from '$lib/paraglide/messages';import type { ContainerDetailsDto } from '$lib/types/container.type';import { format, formatDistanceToNow } from 'date-fns';import { InfoIcon, StartIcon, StopIcon, NetworksIcon, VolumesIcon, HealthIcon } from '$lib/icons';+ import { containerService } from '$lib/services/container-service';+ import { toast } from 'svelte-sonner';interface Props {container: ContainerDetailsDto;primaryIpAddress: string;+ autoUpdateEnabled?: boolean;+ autoUpdateLabelControlled?: boolean;+ onAutoUpdateChange?: (enabled: boolean) => void;onViewPortMappings?: () => void;}- let { container, primaryIpAddress, onViewPortMappings }: Props = $props();+ let { container, primaryIpAddress, autoUpdateEnabled = true, autoUpdateLabelControlled = false, onAutoUpdateChange, onViewPortMappings }: Props = $props();++ let autoUpdateToggling = $state(false);++ async function handleAutoUpdateToggle(checked: boolean) {+ autoUpdateToggling = true;+ try {+ await containerService.setAutoUpdate(container.id, checked);+ onAutoUpdateChange?.(checked);+ toast.success(checked ? m.auto_update_enabled_toast() : m.auto_update_disabled_toast());+ } catch {+ toast.error(m.auto_update_failed());+ } finally {+ autoUpdateToggling = false;+ }+ }function parseDockerDate(input: string | Date | undefined | null): Date | null {if (!input) return null;@@ -242,6 +263,25 @@</Card.Content></Card.Root>+ <Card.Root variant="subtle">+ <Card.Content class="flex flex-col gap-2 p-4">+ <div class="text-muted-foreground text-xs font-semibold tracking-wide uppercase">{m.auto_update_title()}</div>+ <div class="flex items-center gap-3">+ <Switch+ checked={autoUpdateEnabled}+ disabled={autoUpdateToggling || autoUpdateLabelControlled}+ onCheckedChange={handleAutoUpdateToggle}+ />+ <span class="text-foreground text-sm font-medium">+ {autoUpdateEnabled ? m.common_enabled() : m.common_disabled()}+ </span>+ </div>+ {#if autoUpdateLabelControlled}+ <span class="text-muted-foreground text-xs">{m.auto_update_controlled_by_label()}</span>+ {/if}+ </Card.Content>+ </Card.Root>+<Card.Root variant="subtle"><Card.Content class="flex flex-col gap-2 p-4"><div class="text-muted-foreground text-xs font-semibold tracking-wide uppercase">{m.common_ports()}</div>