Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: Add per-container redeploy button (#2034)
Michael Kaltner8dba9b043ca0
diff --git a/backend/internal/common/errors.go b/backend/internal/common/errors.goindex 5eeb26052..a02b75912 100644--- a/backend/internal/common/errors.go+++ b/backend/internal/common/errors.go@@ -172,6 +172,14 @@ func (e *ContainerRestartError) Error() string {return fmt.Sprintf("Failed to restart container: %v", e.Err)}+type ContainerRedeployError struct {+ Err error+}++func (e *ContainerRedeployError) Error() string {+ return fmt.Sprintf("Failed to redeploy container: %v", e.Err)+}+type ContainerDeleteError struct {Err error}diff --git a/backend/internal/huma/handlers/containers.go b/backend/internal/huma/handlers/containers.goindex 9f9ac97b9..2c3724f4a 100644--- a/backend/internal/huma/handlers/containers.go+++ b/backend/internal/huma/handlers/containers.go@@ -191,6 +191,16 @@ func RegisterContainers(api huma.API, containerSvc *services.ContainerService, dSecurity: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},}, h.RestartContainer)+ huma.Register(api, huma.Operation{+ OperationID: "redeploy-container",+ Method: http.MethodPost,+ Path: "/environments/{id}/containers/{containerId}/redeploy",+ Summary: "Redeploy container",+ Description: "Pull latest image and recreate container",+ Tags: []string{"Containers"},+ Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},+ }, h.RedeployContainer)+huma.Register(api, huma.Operation{OperationID: "delete-container",Method: http.MethodDelete,@@ -624,6 +634,46 @@ func (h *ContainerHandler) RestartContainer(ctx context.Context, input *Containe}, nil}+func (h *ContainerHandler) RedeployContainer(ctx context.Context, input *ContainerActionInput) (*GetContainerOutput, error) {+ if h.containerService == nil {+ return nil, huma.Error500InternalServerError("service not available")+ }++ user, exists := humamw.GetCurrentUserFromContext(ctx)+ if !exists {+ return nil, huma.Error401Unauthorized("not authenticated")+ }++ newContainerID, err := h.containerService.RedeployContainer(ctx, input.ContainerID, *user)+ if err != nil {+ return nil, huma.Error500InternalServerError((&common.ContainerRedeployError{Err: err}).Error())+ }++ // Fetch full container details to return (consistent with other endpoints)+ containerInspect, inspectErr := h.containerService.GetContainerByID(ctx, newContainerID)+ if inspectErr == nil {+ details := containertypes.NewDetails(containerInspect)++ return &GetContainerOutput{+ Body: ContainerDetailsResponse{+ Success: true,+ Data: details,+ },+ }, nil+ }++ // Container was redeployed successfully, but we couldn't fetch full details.+ // Return minimal response with just the ID so frontend can still navigate.+ return &GetContainerOutput{+ Body: ContainerDetailsResponse{+ Success: true,+ Data: containertypes.Details{+ ID: newContainerID,+ },+ },+ }, nil+}+func (h *ContainerHandler) DeleteContainer(ctx context.Context, input *DeleteContainerInput) (*DeleteContainerOutput, error) {if h.containerService == nil {return nil, huma.Error500InternalServerError("service not available")diff --git a/backend/internal/models/event.go b/backend/internal/models/event.goindex 796f958f8..b204e5128 100644--- a/backend/internal/models/event.go+++ b/backend/internal/models/event.go@@ -18,6 +18,7 @@ const (EventTypeContainerCreate EventType = "container.create"EventTypeContainerScan EventType = "container.scan"EventTypeContainerUpdate EventType = "container.update"+ EventTypeContainerDeploy EventType = "container.deploy"EventTypeContainerError EventType = "container.error"EventTypeImagePull EventType = "image.pull"diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.goindex 54097e7ea..20eb55fb6 100644--- a/backend/internal/services/container_service.go+++ b/backend/internal/services/container_service.go@@ -57,6 +57,176 @@ func NewContainerService(db *database.DB, eventService *EventService, dockerServ}}+func buildCleanNetworkingConfigInternal(containerInspect container.InspectResponse, apiVersion string) *network.NetworkingConfig {+ if containerInspect.NetworkSettings == nil || len(containerInspect.NetworkSettings.Networks) == 0 {+ return nil+ }++ endpointsConfig := libarcane.SanitizeContainerCreateEndpointSettingsForDockerAPI(containerInspect.NetworkSettings.Networks, apiVersion)+ for networkName, endpoint := range endpointsConfig {+ if endpoint == nil {+ continue+ }++ endpointCopy := *endpoint+ endpointCopy.IPAMConfig = nil+ endpointsConfig[networkName] = &endpointCopy+ }++ if len(endpointsConfig) == 0 {+ return nil+ }++ return &network.NetworkingConfig{+ EndpointsConfig: endpointsConfig,+ }+}++func buildRedeployBackupNameInternal(containerName, containerID string) string {+ backupName := containerName+ if backupName == "" {+ backupName = "arcane-redeploy"+ if len(containerID) >= 12 {+ backupName = fmt.Sprintf("%s-%s", backupName, containerID[:12])+ }+ }++ return fmt.Sprintf("%s-arcane-redeploy-%d", backupName, time.Now().Unix())+}++func shouldStartRedeployedContainerInternal(containerInfo container.InspectResponse, wasRunning bool) bool {+ if !wasRunning && containerInfo.HostConfig == nil {+ return false+ }++ shouldStart := wasRunning+ if containerInfo.HostConfig != nil {+ rp := containerInfo.HostConfig.RestartPolicy.Name+ if rp == "always" || rp == "unless-stopped" || rp == "on-failure" {+ shouldStart = true+ }+ }++ return shouldStart+}++func (s *ContainerService) pullRedeployImageInternal(ctx context.Context, dockerClient *client.Client, imageName, containerID, containerName string, user models.User) error {+ settings := s.settingsService.GetSettingsConfig()+ pullCtx, pullCancel := timeouts.WithTimeout(ctx, settings.DockerImagePullTimeout.AsInt(), timeouts.DefaultDockerImagePull)+ defer pullCancel()++ pullOptions, authErr := s.imageService.getPullOptionsWithAuth(ctx, imageName, nil)+ if authErr != nil {+ slog.WarnContext(ctx, "failed to get registry authentication for container redeploy pull; proceeding without auth",+ "image", imageName,+ "error", authErr.Error(),+ )+ pullOptions = client.ImagePullOptions{}+ }++ reader, pullErr := dockerClient.ImagePull(pullCtx, imageName, pullOptions)+ if pullErr != nil && shouldRetryAnonymousPullInternal(pullOptions, pullErr) {+ slog.WarnContext(ctx, "container redeploy image pull failed with registry auth; retrying anonymously",+ "image", imageName,+ "error", pullErr.Error(),+ )+ pullOptions = client.ImagePullOptions{}+ reader, pullErr = dockerClient.ImagePull(pullCtx, imageName, pullOptions)+ }+ if pullErr != nil {+ if errors.Is(pullCtx.Err(), context.DeadlineExceeded) {+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, containerName, user.ID, user.Username, "0", pullErr, models.JSON{+ "action": "redeploy",+ "step": "pull_image_timeout",+ "image": imageName,+ })+ return fmt.Errorf("image pull timed out for %s (increase DOCKER_IMAGE_PULL_TIMEOUT or setting)", imageName)+ }++ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, containerName, user.ID, user.Username, "0", pullErr, models.JSON{+ "action": "redeploy",+ "step": "pull_image",+ "image": imageName,+ })+ return fmt.Errorf("failed to pull image %s: %w", imageName, pullErr)+ }+ defer func() { _ = reader.Close() }()++ streamErr := dockerutils.ConsumeJSONMessageStream(reader, nil)+ if streamErr != nil {+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, containerName, user.ID, user.Username, "0", streamErr, models.JSON{+ "action": "redeploy",+ "step": "complete_pull",+ "image": imageName,+ })+ return fmt.Errorf("failed to complete image pull: %w", streamErr)+ }++ return nil+}++func (s *ContainerService) prepareContainerForRedeployInternal(ctx context.Context, dockerClient *client.Client, containerID, containerName, backupName string, wasRunning bool, user models.User) error {+ if containerName != "" {+ if _, err := dockerClient.ContainerRename(ctx, containerID, client.ContainerRenameOptions{NewName: backupName}); err != nil {+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, containerName, user.ID, user.Username, "0", err, models.JSON{+ "action": "redeploy",+ "step": "rename_old",+ "backupName": backupName,+ })+ return fmt.Errorf("failed to rename existing container: %w", err)+ }+ }++ if !wasRunning {+ return nil+ }++ timeout := 30+ _, err := dockerClient.ContainerStop(ctx, containerID, client.ContainerStopOptions{Timeout: &timeout})+ if err == nil {+ return nil+ }++ if containerName != "" {+ if _, renameErr := dockerClient.ContainerRename(ctx, containerID, client.ContainerRenameOptions{NewName: containerName}); renameErr != nil {+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, containerName, user.ID, user.Username, "0", renameErr, models.JSON{+ "action": "redeploy",+ "step": "restore_name_after_stop_failure",+ })+ }+ }++ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, containerName, user.ID, user.Username, "0", err, models.JSON{+ "action": "redeploy",+ "step": "stop",+ })+ return fmt.Errorf("failed to stop container: %w", err)+}++func (s *ContainerService) restoreContainerAfterRedeployFailureInternal(ctx context.Context, dockerClient *client.Client, containerID, containerName, backupName, failedStep string, wasRunning bool, user models.User) {+ if wasRunning {+ if _, startErr := dockerClient.ContainerStart(ctx, containerID, client.ContainerStartOptions{}); startErr != nil {+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, containerName, user.ID, user.Username, "0", startErr, models.JSON{+ "action": "redeploy",+ "step": "restore_start_original",+ "failedStep": failedStep,+ })+ }+ }++ if containerName == "" {+ return+ }++ if _, renameErr := dockerClient.ContainerRename(ctx, containerID, client.ContainerRenameOptions{NewName: containerName}); renameErr != nil {+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, backupName, user.ID, user.Username, "0", renameErr, models.JSON{+ "action": "redeploy",+ "step": "restore_name",+ "failedStep": failedStep,+ })+ }+}+func (s *ContainerService) StartContainer(ctx context.Context, containerID string, user models.User) error {dockerClient, err := s.dockerService.GetClient(ctx)if err != nil {@@ -130,6 +300,126 @@ func (s *ContainerService) RestartContainer(ctx context.Context, containerID strreturn err}+func (s *ContainerService) RedeployContainer(ctx context.Context, containerID string, user models.User) (string, error) {+ dockerClient, err := s.dockerService.GetClient(ctx)+ if err != nil {+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{+ "action": "redeploy",+ "step": "get_client",+ })+ return "", fmt.Errorf("failed to connect to Docker: %w", err)+ }++ containerJSON, err := libarcane.ContainerInspectWithCompatibility(ctx, dockerClient, containerID, client.ContainerInspectOptions{})+ if err != nil {+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{+ "action": "redeploy",+ "step": "inspect",+ })+ return "", fmt.Errorf("failed to inspect container: %w", err)+ }++ containerInfo := containerJSON.Container+ if containerInfo.Config == nil {+ err = errors.New("container config is nil")+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, "", user.ID, user.Username, "0", err, models.JSON{+ "action": "redeploy",+ "step": "validate_config",+ })+ return "", fmt.Errorf("failed to redeploy container: %w", err)+ }++ containerName := strings.TrimPrefix(containerInfo.Name, "/")+ imageName := containerInfo.Config.Image+ wasRunning := containerInfo.State != nil && containerInfo.State.Running+ apiVersion := libarcane.DetectDockerAPIVersion(ctx, dockerClient)++ metadata := models.JSON{+ "action": "redeploy",+ "containerId": containerID,+ "containerName": containerName,+ "image": imageName,+ }++ if imageName != "" {+ if err := s.pullRedeployImageInternal(ctx, dockerClient, imageName, containerID, containerName, user); err != nil {+ return "", err+ }+ }++ backupName := buildRedeployBackupNameInternal(containerName, containerID)+ if err := s.prepareContainerForRedeployInternal(ctx, dockerClient, containerID, containerName, backupName, wasRunning, user); err != nil {+ return "", err+ }++ networkingConfig := buildCleanNetworkingConfigInternal(containerInfo, apiVersion)++ newConfig := *containerInfo.Config+ if len(containerID) >= 12 && newConfig.Hostname == containerID[:12] {+ newConfig.Hostname = ""+ }++ createResp, err := libarcane.ContainerCreateWithCompatibilityForAPIVersion(ctx, dockerClient, client.ContainerCreateOptions{+ Config: &newConfig,+ HostConfig: containerInfo.HostConfig,+ NetworkingConfig: networkingConfig,+ Name: containerName,+ }, apiVersion)+ if err != nil {+ s.restoreContainerAfterRedeployFailureInternal(ctx, dockerClient, containerID, containerName, backupName, "create", wasRunning, user)+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, containerName, user.ID, user.Username, "0", err, models.JSON{+ "action": "redeploy",+ "step": "create",+ "image": imageName,+ })+ return "", fmt.Errorf("failed to recreate container: %w", err)+ }++ if shouldStartRedeployedContainerInternal(containerInfo, wasRunning) {+ _, err = dockerClient.ContainerStart(ctx, createResp.ID, client.ContainerStartOptions{})+ if err != nil {+ if _, removeErr := dockerClient.ContainerRemove(ctx, createResp.ID, client.ContainerRemoveOptions{Force: true}); removeErr != nil {+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", createResp.ID, containerName, user.ID, user.Username, "0", removeErr, models.JSON{+ "action": "redeploy",+ "step": "cleanup_failed_start",+ })+ }+ s.restoreContainerAfterRedeployFailureInternal(ctx, dockerClient, containerID, containerName, backupName, "start", wasRunning, user)+ s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", createResp.ID, containerName, user.ID, user.Username, "0", err, models.JSON{+ "action": "redeploy",+ "step": "start",+ "image": imageName,+ })+ return "", fmt.Errorf("failed to start new container: %w", err)+ }+ }++ slog.InfoContext(ctx, "container redeployed successfully",+ "oldContainerId", containerID,+ "newContainerId", createResp.ID,+ "containerName", containerName,+ "image", imageName,+ )++ if _, err := dockerClient.ContainerRemove(ctx, containerID, client.ContainerRemoveOptions{+ Force: true,+ RemoveVolumes: false,+ RemoveLinks: false,+ }); err != nil {+ slog.WarnContext(ctx, "failed to remove old container after successful redeploy",+ "containerId", containerID,+ "backupName", backupName,+ "error", err,+ )+ }++ if logErr := s.eventService.LogContainerEvent(ctx, models.EventTypeContainerDeploy, createResp.ID, containerName, user.ID, user.Username, "0", metadata); logErr != nil {+ slog.WarnContext(ctx, "failed to log deploy event", "err", logErr)+ }++ return createResp.ID, nil+}+func (s *ContainerService) GetContainerByID(ctx context.Context, id string) (*container.InspectResponse, error) {dockerClient, err := s.dockerService.GetClient(ctx)if err != nil {diff --git a/backend/internal/services/container_service_test.go b/backend/internal/services/container_service_test.goindex 5787bbb13..9a2e640eb 100644--- a/backend/internal/services/container_service_test.go+++ b/backend/internal/services/container_service_test.go@@ -1,10 +1,13 @@package servicesimport (+ "net/netip""testing""github.com/getarcaneapp/arcane/backend/internal/utils/pagination"containertypes "github.com/getarcaneapp/arcane/types/container"+ "github.com/moby/moby/api/types/container"+ "github.com/moby/moby/api/types/network""github.com/stretchr/testify/require")@@ -71,6 +74,27 @@ func TestGroupContainersByProjectUsesNoProjectBucket(t *testing.T) {require.Equal(t, containerNoProjectGroup, getContainerProjectNameInternal(groups[1].Items[1]))}+func TestBuildCleanNetworkingConfigInternalPreservesEndpointSettings(t *testing.T) {+ containerInspect := container.InspectResponse{+ NetworkSettings: &container.NetworkSettings{+ Networks: map[string]*network.EndpointSettings{+ "bridge": {+ Aliases: []string{"svc"},+ IPAddress: netip.MustParseAddr("172.17.0.2"),+ IPAMConfig: &network.EndpointIPAMConfig{IPv4Address: netip.MustParseAddr("172.17.0.5")},+ },+ },+ },+ }++ out := buildCleanNetworkingConfigInternal(containerInspect, "1.44")+ require.NotNil(t, out)+ require.Contains(t, out.EndpointsConfig, "bridge")+ require.Equal(t, []string{"svc"}, out.EndpointsConfig["bridge"].Aliases)+ require.Equal(t, netip.MustParseAddr("172.17.0.2"), out.EndpointsConfig["bridge"].IPAddress)+ require.Nil(t, out.EndpointsConfig["bridge"].IPAMConfig)+}+func newGroupedContainerSummary(name string, project string) containertypes.Summary {labels := map[string]string{}if project != "" {diff --git a/cli/internal/types/endpoints.go b/cli/internal/types/endpoints.goindex cfda65f7e..f7268d5f3 100644--- a/cli/internal/types/endpoints.go+++ b/cli/internal/types/endpoints.go@@ -34,13 +34,14 @@ type ArcaneApiEndpoints struct {EnvironmentVersionEndpoint string// Containers- ContainersEndpoint string- ContainerEndpoint string- ContainerStartEndpoint string- ContainerStopEndpoint string- ContainerRestartEndpoint string- ContainerUpdateEndpoint string- ContainersCountsEndpoint string+ ContainersEndpoint string+ ContainerEndpoint string+ ContainerStartEndpoint string+ ContainerStopEndpoint string+ ContainerRestartEndpoint string+ ContainerUpdateEndpoint string+ ContainerRedeployEndpoint string+ ContainersCountsEndpoint string// ImagesImagesEndpoint string@@ -197,13 +198,14 @@ var Endpoints = ArcaneApiEndpoints{ //nolint:gosec // static endpoint paths; autEnvironmentVersionEndpoint: "/api/environments/%s/version",// Containers- ContainersEndpoint: "/api/environments/%s/containers",- ContainerEndpoint: "/api/environments/%s/containers/%s",- ContainerStartEndpoint: "/api/environments/%s/containers/%s/start",- ContainerStopEndpoint: "/api/environments/%s/containers/%s/stop",- ContainerRestartEndpoint: "/api/environments/%s/containers/%s/restart",- ContainerUpdateEndpoint: "/api/environments/%s/containers/%s/update",- ContainersCountsEndpoint: "/api/environments/%s/containers/counts",+ ContainersEndpoint: "/api/environments/%s/containers",+ ContainerEndpoint: "/api/environments/%s/containers/%s",+ ContainerStartEndpoint: "/api/environments/%s/containers/%s/start",+ ContainerStopEndpoint: "/api/environments/%s/containers/%s/stop",+ ContainerRestartEndpoint: "/api/environments/%s/containers/%s/restart",+ ContainerUpdateEndpoint: "/api/environments/%s/containers/%s/update",+ ContainerRedeployEndpoint: "/api/environments/%s/containers/%s/redeploy",+ ContainersCountsEndpoint: "/api/environments/%s/containers/counts",// ImagesImagesEndpoint: "/api/environments/%s/images",@@ -388,6 +390,10 @@ func (e ArcaneApiEndpoints) ContainerUpdate(envID, containerID string) string {return fmt.Sprintf(e.ContainerUpdateEndpoint, envID, containerID)}+func (e ArcaneApiEndpoints) ContainerRedeploy(envID, containerID string) string {+ return fmt.Sprintf(e.ContainerRedeployEndpoint, envID, containerID)+}+func (e ArcaneApiEndpoints) ContainersCounts(envID string) string {return fmt.Sprintf(e.ContainersCountsEndpoint, envID)}diff --git a/cli/pkg/containers/cmd.go b/cli/pkg/containers/cmd.goindex 066ccc708..0c916d2fe 100644--- a/cli/pkg/containers/cmd.go+++ b/cli/pkg/containers/cmd.go@@ -343,6 +343,50 @@ var containersUpdateCmd = &cobra.Command{},}+var containersRedeployCmd = &cobra.Command{+ Use: "redeploy <container-id|name>",+ Short: "Redeploy a container (pull image and recreate)",+ Args: cobra.ExactArgs(1),+ SilenceUsage: true,+ RunE: func(cmd *cobra.Command, args []string) error {+ c, err := client.NewFromConfig()+ if err != nil {+ return err+ }++ resolved, _, err := resolveContainer(cmd.Context(), c, args[0], false)+ if err != nil {+ return err+ }++ c.SetTimeout(30 * time.Minute)++ path := types.Endpoints.ContainerRedeploy(c.EnvID(), resolved.ID)+ resp, err := c.Post(cmd.Context(), path, nil)+ if err != nil {+ return fmt.Errorf("failed to redeploy container: %w", err)+ }+ defer func() { _ = resp.Body.Close() }()++ var result base.ApiResponse[container.Details]+ if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {+ return fmt.Errorf("failed to parse response: %w", err)+ }++ if jsonOutput {+ resultBytes, err := json.MarshalIndent(result.Data, "", " ")+ if err != nil {+ return fmt.Errorf("failed to marshal JSON: %w", err)+ }+ fmt.Println(string(resultBytes))+ return nil+ }++ output.Success("Container %s redeployed successfully", containerDisplayName(resolved))+ return nil+ },+}+var containersDeleteCmd = &cobra.Command{Use: "delete <container-id|name>",Aliases: []string{"rm", "remove"},@@ -582,6 +626,7 @@ func init() {ContainersCmd.AddCommand(containersStopCmd)ContainersCmd.AddCommand(containersRestartCmd)ContainersCmd.AddCommand(containersUpdateCmd)+ ContainersCmd.AddCommand(containersRedeployCmd)ContainersCmd.AddCommand(containersDeleteCmd)ContainersCmd.AddCommand(containersCountsCmd)ContainersCmd.AddCommand(containersCreateCmd)@@ -620,6 +665,7 @@ func init() {containersStopCmd.Flags().BoolVar(&jsonOutput, "json", false, "Output in JSON format")containersRestartCmd.Flags().BoolVar(&jsonOutput, "json", false, "Output in JSON format")containersUpdateCmd.Flags().BoolVar(&jsonOutput, "json", false, "Output in JSON format")+ containersRedeployCmd.Flags().BoolVar(&jsonOutput, "json", false, "Output in JSON format")containersDeleteCmd.Flags().BoolVar(&jsonOutput, "json", false, "Output in JSON format")containersCountsCmd.Flags().BoolVar(&jsonOutput, "json", false, "Output in JSON format")}diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex fada831a9..471d20915 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -241,7 +241,11 @@"common_confirm_removal_message": "Are you sure you want to remove this {type}? This action is DESTRUCTIVE and cannot be undone.","common_confirm_destroy_message": "Are you sure you want to destroy this {type}? This action is DESTRUCTIVE and will remove associated resources and cannot be undone.","common_confirm_redeploy_title": "Confirm Redeploy",- "common_confirm_redeploy_message": "Are you sure you want to redeploy this project? This will pull the latest images and recreate containers as needed.",+ "common_confirm_redeploy_message": "Are you sure you want to redeploy this project? This will pull the latest images and recreate the containers as needed.",+ "container_confirm_redeploy_title": "Confirm Container Redeploy",+ "container_confirm_redeploy_message": "Are you sure you want to redeploy this container? This will pull the latest image and recreate it as needed.",+ "container_redeploy_success": "Container redeployed successfully.",+ "container_redeploy_failed": "Failed to redeploy container","confirm_remove_project_files": "Remove project files","confirm_remove_volumes_warning": "Remove volumes (Warning: Data will be lost)","_comment_common_ui": "=== COMMON - UI COMPONENTS ===",diff --git a/frontend/src/lib/components/action-buttons.svelte b/frontend/src/lib/components/action-buttons.svelteindex 49139914f..6ab957040 100644--- a/frontend/src/lib/components/action-buttons.svelte+++ b/frontend/src/lib/components/action-buttons.svelte@@ -12,8 +12,9 @@import { m } from '$lib/paraglide/messages';import settingsStore from '$lib/stores/config-store';import { deployOptionsStore } from '$lib/stores/deploy-options.store.svelte';- import { containerService } from '$lib/services/container-service';+ import { containerService, type ContainerDetailsResponse } from '$lib/services/container-service';import { projectService, type DeployProjectOptions } from '$lib/services/project-service';+ import type { Project } from '$lib/types/project.type';import { isDownloadingLine, calculateOverallProgress, areAllLayersComplete } from '$lib/utils/pull-progress';import { sanitizeLogText } from '$lib/utils/log-text';import { EllipsisIcon, DownloadIcon, HammerIcon } from '$lib/icons';@@ -140,8 +141,13 @@}));const redeployMutation = createMutation(() => ({- mutationKey: ['action', 'redeploy', id],- mutationFn: () => tryCatch(projectService.redeployProject(id)),+ mutationKey: ['action', 'redeploy', type, id],+ mutationFn: () =>+ tryCatch(+ (type === 'container' ? containerService.redeployContainer(id) : projectService.redeployProject(id)) as Promise<+ ContainerDetailsResponse | Project+ >+ ),onMutate: () => setLoading('redeploy', true),onSettled: () => setLoading('redeploy', false)}));@@ -407,8 +413,8 @@});} else if (action === 'redeploy') {openConfirmDialog({- title: m.common_confirm_redeploy_title(),- message: m.common_confirm_redeploy_message(),+ title: type === 'container' ? m.container_confirm_redeploy_title() : m.common_confirm_redeploy_title(),+ message: type === 'container' ? m.container_confirm_redeploy_message() : m.common_confirm_redeploy_message(),confirm: {label: m.common_redeploy(),action: async () => {@@ -416,9 +422,18 @@handleApiResultWithCallbacks({result,message: m.common_action_failed_with_type({ action: m.common_redeploy(), type }),- onSuccess: async () => {- toast.success(m.common_redeploy_success({ type: name || type }));- onActionComplete('running');+ onSuccess: async (data) => {+ toast.success(+ type === 'container' ? m.container_redeploy_success() : m.common_redeploy_success({ type: name || type })+ );+ const containerData = data as ContainerDetailsResponse;+ if (type === 'container' && containerData?.data?.id) {+ goto(`/containers/${containerData.data.id}`);+ } else if (type === 'container') {+ goto('/containers');+ } else {+ onActionComplete('running');+ }}});}@@ -868,6 +883,13 @@{/if}{#if type === 'container'}+ <ArcaneButton+ action="redeploy"+ size={adaptiveIconOnly ? 'icon' : 'default'}+ showLabel={!adaptiveIconOnly}+ onclick={() => confirmAction('redeploy')}+ loading={uiLoading.redeploy}+ /><ArcaneButtonaction="remove"size={adaptiveIconOnly ? 'icon' : 'default'}@@ -1003,6 +1025,9 @@{/if}{#if type === 'container'}+ <DropdownMenu.Item onclick={() => confirmAction('redeploy')} disabled={uiLoading.redeploy}>+ {m.common_redeploy()}+ </DropdownMenu.Item><DropdownMenu.Item onclick={() => confirmAction('remove')} disabled={uiLoading.remove}>{m.common_remove()}</DropdownMenu.Item>@@ -1127,6 +1152,7 @@{/if}{#if type === 'container'}+ <ArcaneButton action="redeploy" onclick={() => confirmAction('redeploy')} loading={uiLoading.redeploy} /><ArcaneButton action="remove" onclick={() => confirmAction('remove')} loading={uiLoading.remove} />{:else}<ArcaneButton action="redeploy" onclick={() => confirmAction('redeploy')} loading={uiLoading.redeploy} />@@ -1230,6 +1256,9 @@{/if}{#if type === 'container'}+ <DropdownMenu.Item onclick={() => confirmAction('redeploy')} disabled={uiLoading.redeploy}>+ {m.common_redeploy()}+ </DropdownMenu.Item><DropdownMenu.Item onclick={() => confirmAction('remove')} disabled={uiLoading.remove}>{m.common_remove()}</DropdownMenu.Item>diff --git a/frontend/src/lib/services/container-service.ts b/frontend/src/lib/services/container-service.tsindex a47345571..eaa1326b3 100644--- a/frontend/src/lib/services/container-service.ts+++ b/frontend/src/lib/services/container-service.ts@@ -5,7 +5,8 @@ import type {ContainerSummaryDto,ContainerSummaryGroupDto,ContainerStats,- ContainerCreateRequest+ ContainerCreateRequest,+ ContainerDetailsDto} from '$lib/types/container.type';import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';import { transformPaginationParams } from '$lib/utils/params.util';@@ -17,6 +18,11 @@ export type ContainerListRequestOptions = SearchPaginationSortRequest & {groupByProject?: boolean;};+export interface ContainerDetailsResponse {+ success: boolean;+ data: ContainerDetailsDto;+}+export class ContainerService extends BaseAPIService {private async resolveEnvironmentId(environmentId?: string): Promise<string> {return environmentId ?? (await environmentStore.getCurrentEnvironmentId());@@ -91,6 +97,11 @@ export class ContainerService extends BaseAPIService {const envId = await environmentStore.getCurrentEnvironmentId();return this.handleResponse(this.api.post(`/environments/${envId}/containers/${containerId}/update`));}++ async redeployContainer(containerId: string): Promise<ContainerDetailsResponse> {+ const envId = await environmentStore.getCurrentEnvironmentId();+ return this.handleResponse(this.api.post(`/environments/${envId}/containers/${containerId}/redeploy`));+ }}export const containerService = new ContainerService();diff --git a/frontend/src/routes/(app)/containers/container-table.actions.ts b/frontend/src/routes/(app)/containers/container-table.actions.tsindex b21d6e7e3..4b4b5e83a 100644--- a/frontend/src/routes/(app)/containers/container-table.actions.ts+++ b/frontend/src/routes/(app)/containers/container-table.actions.ts@@ -22,7 +22,7 @@ type ActionDeps = {isBulkLoading: BulkLoadingState;};-type ContainerActionKind = 'start' | 'stop' | 'restart';+type ContainerActionKind = 'start' | 'stop' | 'restart' | 'redeploy';type ContainerActionConfig = {status: ActionStatus;@@ -61,6 +61,12 @@ const containerActionConfigs: Record<ContainerActionKind, ContainerActionConfig>run: (id) => containerService.restartContainer(id),success: () => m.containers_restart_success(),failure: () => m.containers_restart_failed()+ },+ redeploy: {+ status: 'redeploying',+ run: (id) => containerService.redeployContainer(id),+ success: () => m.container_redeploy_success(),+ failure: () => m.container_redeploy_failed()}};@@ -178,6 +184,33 @@ export function createContainerActions({});}+ async function handleRedeployContainer(container: ContainerSummaryDto) {+ const containerName = getContainerDisplayName(container);++ openConfirmDialog({+ title: m.container_confirm_redeploy_title(),+ message: m.container_confirm_redeploy_message(),+ confirm: {+ label: m.common_redeploy(),+ destructive: false,+ action: async () => {+ actionStatus[container.id] = 'redeploying';+ handleApiResultWithCallbacks({+ result: await tryCatch(containerService.redeployContainer(container.id)),+ message: m.container_redeploy_failed(),+ setLoadingState: (value) => {+ actionStatus[container.id] = value ? 'redeploying' : '';+ },+ async onSuccess() {+ toast.success(m.container_redeploy_success());+ await refreshContainers();+ }+ });+ }+ }+ });+ }+async function runBulkAction(ids: string[], config: BulkActionConfig) {if (!ids || ids.length === 0) return;@@ -303,6 +336,7 @@ export function createContainerActions({performContainerAction,handleRemoveContainer,handleUpdateContainer,+ handleRedeployContainer,handleBulkStart,handleBulkStop,handleBulkRestart,diff --git a/frontend/src/routes/(app)/containers/container-table.helpers.ts b/frontend/src/routes/(app)/containers/container-table.helpers.tsindex 9db7f7686..e17387b5d 100644--- a/frontend/src/routes/(app)/containers/container-table.helpers.ts+++ b/frontend/src/routes/(app)/containers/container-table.helpers.ts@@ -1,7 +1,7 @@import { m } from '$lib/paraglide/messages';import type { ContainerSummaryDto } from '$lib/types/container.type';-export type ActionStatus = 'starting' | 'stopping' | 'restarting' | 'updating' | 'removing' | '';+export type ActionStatus = 'starting' | 'stopping' | 'restarting' | 'updating' | 'removing' | 'redeploying' | '';export type StateBadgeVariant = 'green' | 'red' | 'amber';export function parseImageRef(imageRef: string): { repo: string; tag: string } {@@ -30,6 +30,7 @@ const actionStatusMessages: Record<ActionStatus, () => string> = {starting: () => m.common_action_starting(),stopping: () => m.common_action_stopping(),restarting: () => m.common_action_restarting(),+ redeploying: () => m.common_action_redeploying(),updating: () => m.common_action_updating(),removing: () => m.common_action_removing(),'': () => ''diff --git a/frontend/src/routes/(app)/containers/container-table.svelte b/frontend/src/routes/(app)/containers/container-table.svelteindex b31f98642..be8ca50cb 100644--- a/frontend/src/routes/(app)/containers/container-table.svelte+++ b/frontend/src/routes/(app)/containers/container-table.svelte@@ -50,7 +50,8 @@NetworksIcon,ProjectsIcon,InspectIcon,- UpdateIcon+ UpdateIcon,+ RedeployIcon} from '$lib/icons';type FieldVisibility = Record<string, boolean>;@@ -123,6 +124,7 @@performContainerAction,handleRemoveContainer,handleUpdateContainer,+ handleRedeployContainer,handleBulkStart,handleBulkStop,handleBulkRestart,@@ -639,6 +641,15 @@</DropdownMenu.Item>{/if}+ <DropdownMenu.Item onclick={() => handleRedeployContainer(item)} disabled={status === 'redeploying' || isAnyLoading}>+ {#if status === 'redeploying'}+ <Spinner class="size-4" />+ {:else}+ <RedeployIcon class="size-4" />+ {/if}+ {m.common_redeploy()}+ </DropdownMenu.Item>+<DropdownMenu.Separator /><DropdownMenu.Item