Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat(containers): add experimental Convert to Compose for running containers (#3746)
Kyle Mendell9aef34e4ea70
diff --git a/backend/internal/config/schema/schema_test.go b/backend/internal/config/schema/schema_test.goindex 10424d60a..69d136c50 100644--- a/backend/internal/config/schema/schema_test.go+++ b/backend/internal/config/schema/schema_test.go@@ -303,6 +303,7 @@ var expectedSettingOverrideKeys = []string{"enableGravatar","environmentHealthInterval","eventCleanupInterval",+ "experimentalFeaturesEnabled","expiredSessionsCleanupInterval","followProjectSymlinks","gitOperationTimeout",diff --git a/backend/internal/container/handler.go b/backend/internal/container/handler.goindex f9336f958..59e698e15 100644--- a/backend/internal/container/handler.go+++ b/backend/internal/container/handler.go@@ -160,6 +160,15 @@ type CommitContainerOutput struct {Body base.ApiResponse[containertypes.CommitResult]}+type GenerateComposeInput struct {+ EnvironmentID string `path:"id" doc:"Environment ID"`+ Body containertypes.GenerateComposeRequest+}++type GenerateComposeOutput struct {+ Body base.ApiResponse[containertypes.GenerateComposeResponse]+}+func RegisterContainers(api huma.API, containerSvc *ContainerService, dockerSvc *docker.DockerClientService, settingsSvc *settings.SettingsService, activitySvc *activity.ActivityService, appCtx handlerutil.ActivityAppContext) {h := &ContainerHandler{containerService: containerSvc,@@ -281,6 +290,16 @@ func RegisterContainers(api huma.API, containerSvc *ContainerService, dockerSvcSecurity: handlerutil.DefaultOperationSecurity(),}, authz.PermContainersRedeploy, h.RedeployContainer)+ middleware.RegisterWithPermission(api, huma.Operation{+ OperationID: "generate-compose",+ Method: http.MethodPost,+ Path: "/environments/{id}/containers/generate-compose",+ Summary: "Generate compose file",+ Description: "Generate a compose file from existing containers",+ Tags: []string{"Containers"},+ Security: handlerutil.DefaultOperationSecurity(),+ }, authz.PermContainersRead, h.GenerateCompose)+middleware.RegisterWithPermission(api, huma.Operation{OperationID: "get-container-edit-config",Method: http.MethodGet,@@ -661,6 +680,20 @@ func (h *ContainerHandler) GetContainer(ctx context.Context, input *GetContainer}, nil}+func (h *ContainerHandler) GenerateCompose(ctx context.Context, input *GenerateComposeInput) (*GenerateComposeOutput, error) {+ composeContent, err := h.containerService.GenerateCompose(ctx, input.Body.ContainerIDs)+ if err != nil {+ return nil, huma.Error500InternalServerError(errors.WithMessage(err, "Failed to generate compose file").Error())+ }++ return &GenerateComposeOutput{+ Body: base.ApiResponse[containertypes.GenerateComposeResponse]{+ Success: true,+ Data: containertypes.GenerateComposeResponse{ComposeContent: composeContent},+ },+ }, nil+}+func (h *ContainerHandler) StartContainer(ctx context.Context, input *ContainerActionInput) (*ContainerActionOutput, error) {return h.runContainerActionInternal(ctx, input, containerActionConfigInternal{ActivityType: activitytypes.TypeContainerStart,diff --git a/backend/internal/container/service.go b/backend/internal/container/service.goindex c403e75bc..1c7865c23 100644--- a/backend/internal/container/service.go+++ b/backend/internal/container/service.go@@ -636,6 +636,19 @@ func (s *ContainerService) findComposeServiceContainerIDInternal(ctx context.Conreturn firstMatch}+func (s *ContainerService) GenerateCompose(ctx context.Context, containerIDs []string) (string, error) {+ proj, err := projects.ComposeGenerate(ctx, s.dockerService.DockerHost(), "", containerIDs)+ if err != nil {+ return "", err+ }++ content, err := proj.MarshalYAML()+ if err != nil {+ return "", errors.WithMessage(err, "failed to marshal generated compose project")+ }+ return string(content), nil+}+func (s *ContainerService) RedeployContainer(ctx context.Context, containerID string, user common.User) (string, error) {dockerClient, err := s.dockerService.GetClient(ctx)if err != nil {diff --git a/backend/internal/settings/model.go b/backend/internal/settings/model.goindex 12767d225..b09414ddf 100644--- a/backend/internal/settings/model.go+++ b/backend/internal/settings/model.go@@ -66,16 +66,17 @@ func (s SettingVariable) AsDurationSeconds() time.Duration {type Settings struct {// General category- ProjectsDirectory SettingVariable `key:"projectsDirectory,envOverride" meta:"label=Projects Directory;type=text;keywords=projects,directory,path,folder,location,storage,files,compose,docker-compose;category=internal;description=Configure where project files are stored"`- TemplatesDirectory SettingVariable `key:"templatesDirectory,envOverride" meta:"label=Templates Directory;type=text;keywords=templates,directory,path,folder,location,storage,compose,docker-compose;category=internal;description=Configure where local compose template folders are discovered"`- FollowProjectSymlinks SettingVariable `key:"followProjectSymlinks,envOverride" meta:"label=Follow Project Symlinks;type=boolean;keywords=projects,symlink,symlinks,symbolic links,compose,directory,discovery;category=general;description=Treat symlinked child directories inside the projects directory as Docker Compose projects"`- SwarmStackSourcesDirectory SettingVariable `key:"swarmStackSourcesDirectory,envOverride" meta:"label=Swarm Stack Sources Directory;type=text;keywords=swarm,stacks,stack,source,sources,directory,path,folder,location,storage,compose,env;category=internal;description=Configure where swarm stack source files are stored"`- DiskUsagePath SettingVariable `key:"diskUsagePath" meta:"label=Disk Usage Path;type=text;keywords=disk,usage,path,storage,folder,files;category=general;description=Path used for disk usage calculations"`- BaseServerURL SettingVariable `key:"baseServerUrl" meta:"label=Base Server URL;type=text;keywords=base,url,server,domain,host,endpoint,address,link;category=general;description=Set the base URL for the application"`- EnableGravatar SettingVariable `key:"enableGravatar,authrequired" meta:"label=Enable Gravatar;type=boolean;keywords=gravatar,avatar,profile,picture,image,user,photo;category=users;description=Enable Gravatar profile pictures for users"`- AvatarMaxUploadSizeMb SettingVariable `key:"avatarMaxUploadSizeMb,authrequired" meta:"label=Avatar Max Upload Size (MB);type=number;keywords=avatar,profile,picture,upload,size,limit,maximum,image,user,photo,mb;category=users;description=Maximum size in MB for profile picture uploads (default: 2)"`- DefaultShell SettingVariable `key:"defaultShell" meta:"label=Default Shell;type=text;keywords=shell,default,shellpath,path,login;category=general;description=Default shell to use for commands"`- EnvironmentHealthInterval SettingVariable `key:"environmentHealthInterval" meta:"label=Environment Health Check Interval;type=cron;keywords=environment,health,check,interval,frequency,heartbeat,status,monitoring,uptime,jobs,schedule;description=How often to check environment connectivity (cron expression)" catmeta:"id=jobschedule;title=Automations;icon=jobs;url=/settings/jobs;description=Configure how often Arcane background jobs run"`+ ProjectsDirectory SettingVariable `key:"projectsDirectory,envOverride" meta:"label=Projects Directory;type=text;keywords=projects,directory,path,folder,location,storage,files,compose,docker-compose;category=internal;description=Configure where project files are stored"`+ TemplatesDirectory SettingVariable `key:"templatesDirectory,envOverride" meta:"label=Templates Directory;type=text;keywords=templates,directory,path,folder,location,storage,compose,docker-compose;category=internal;description=Configure where local compose template folders are discovered"`+ FollowProjectSymlinks SettingVariable `key:"followProjectSymlinks,envOverride" meta:"label=Follow Project Symlinks;type=boolean;keywords=projects,symlink,symlinks,symbolic links,compose,directory,discovery;category=general;description=Treat symlinked child directories inside the projects directory as Docker Compose projects"`+ SwarmStackSourcesDirectory SettingVariable `key:"swarmStackSourcesDirectory,envOverride" meta:"label=Swarm Stack Sources Directory;type=text;keywords=swarm,stacks,stack,source,sources,directory,path,folder,location,storage,compose,env;category=internal;description=Configure where swarm stack source files are stored"`+ DiskUsagePath SettingVariable `key:"diskUsagePath" meta:"label=Disk Usage Path;type=text;keywords=disk,usage,path,storage,folder,files;category=general;description=Path used for disk usage calculations"`+ BaseServerURL SettingVariable `key:"baseServerUrl" meta:"label=Base Server URL;type=text;keywords=base,url,server,domain,host,endpoint,address,link;category=general;description=Set the base URL for the application"`+ EnableGravatar SettingVariable `key:"enableGravatar,authrequired" meta:"label=Enable Gravatar;type=boolean;keywords=gravatar,avatar,profile,picture,image,user,photo;category=users;description=Enable Gravatar profile pictures for users"`+ AvatarMaxUploadSizeMb SettingVariable `key:"avatarMaxUploadSizeMb,authrequired" meta:"label=Avatar Max Upload Size (MB);type=number;keywords=avatar,profile,picture,upload,size,limit,maximum,image,user,photo,mb;category=users;description=Maximum size in MB for profile picture uploads (default: 2)"`+ DefaultShell SettingVariable `key:"defaultShell" meta:"label=Default Shell;type=text;keywords=shell,default,shellpath,path,login;category=general;description=Default shell to use for commands"`+ ExperimentalFeaturesEnabled SettingVariable `key:"experimentalFeaturesEnabled,authrequired" meta:"label=Experimental Features;type=boolean;keywords=experimental,features,beta,preview,flags;category=general;description=Enable experimental features that may change or be removed in future releases"`+ EnvironmentHealthInterval SettingVariable `key:"environmentHealthInterval" meta:"label=Environment Health Check Interval;type=cron;keywords=environment,health,check,interval,frequency,heartbeat,status,monitoring,uptime,jobs,schedule;description=How often to check environment connectivity (cron expression)" catmeta:"id=jobschedule;title=Automations;icon=jobs;url=/settings/jobs;description=Configure how often Arcane background jobs run"`// Docker categoryAutoUpdate SettingVariable `key:"autoUpdate" meta:"label=Auto Update;type=boolean;keywords=auto,update,automatic,upgrade,refresh,restart,deploy;category=internal;description=Automatically update containers when new images are available"`diff --git a/backend/internal/settings/service.go b/backend/internal/settings/service.goindex f34979971..bc8c01b06 100644--- a/backend/internal/settings/service.go+++ b/backend/internal/settings/service.go@@ -232,6 +232,7 @@ func DefaultSettingsConfig() *Settings {VolumeHelperIdleTimeout: SettingVariable{Value: "10"},BaseServerURL: SettingVariable{Value: "http://localhost"},EnableGravatar: SettingVariable{Value: "true"},+ ExperimentalFeaturesEnabled: SettingVariable{Value: "false"},AvatarMaxUploadSizeMb: SettingVariable{Value: "2"},DefaultShell: SettingVariable{Value: "/bin/sh"},DockerHost: SettingVariable{Value: "unix:///var/run/docker.sock"},diff --git a/backend/pkg/projects/cmds.go b/backend/pkg/projects/cmds.goindex 0a2990e6a..35a818e32 100644--- a/backend/pkg/projects/cmds.go+++ b/backend/pkg/projects/cmds.go@@ -138,6 +138,18 @@ func ComposePs(ctx context.Context, dockerHost string, proj *types.Project, servreturn c.svc.Ps(ctx, proj.Name, api.PsOptions{All: all, Services: services})}+func ComposeGenerate(ctx context.Context, dockerHost, projectName string, containerIDs []string) (*types.Project, error) {+ c, shared, err := plainComposeClientInternal(ctx, dockerHost)+ if err != nil {+ return nil, err+ }+ if !shared {+ defer func() { _ = c.Close() }()+ }++ return c.svc.Generate(ctx, api.GenerateOptions{ProjectName: projectName, Containers: containerIDs})+}+func ComposeDown(ctx context.Context, proj *types.Project, removeVolumes bool) error {downCtx, cancel := detachFromHTTPContextInternal(ctx, defaultComposeTimeout)defer cancel()diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex b837a74d8..9cc6bfaa1 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -597,6 +597,11 @@"containers_bulk_stop": "Stop ({count})","containers_bulk_restart": "Restart ({count})","containers_bulk_remove": "Remove ({count})",+ "containers_bulk_convert": "Convert to Compose ({count})",+ "remove_original_containers": "Remove original container(s) after creation",+ "convert_create_message": "This project was generated from existing container(s). The originals keep running unless you remove them — removal happens immediately after creation, before the project is deployed, and cannot be undone.",+ "experimental_features": "Experimental Features",+ "experimental_features_description": "Enable features that may change or be removed in future releases","containers_bulk_start_confirm_title": "Start {count} Container(s)","containers_bulk_start_confirm_message": "Are you sure you want to start {count} container(s)?","containers_bulk_stop_confirm_title": "Stop {count} Container(s)",diff --git a/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte b/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelteindex 33c44501d..bb1367b82 100644--- a/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte+++ b/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte@@ -18,6 +18,7 @@import { ResetIcon, SearchIcon, FilterIcon } from '#lib/icons';import type { BulkAction } from './arcane-table.types.svelte';import * as Popover from '#lib/components/ui/popover/index.js';+ import * as ArcaneTooltip from '#lib/components/arcane-tooltip';let {table,@@ -190,17 +191,26 @@<div class="order-2 flex shrink-0 items-center gap-1.5">{#each bulkActions as bulkAction (bulkAction.id)}{@const actionType = bulkAction.action === 'up' ? 'start' : bulkAction.action === 'down' ? 'stop' : bulkAction.action}- <ArcaneButton- action={actionType}- size="sm"- icon={bulkAction.icon}- customLabel={bulkAction.label}- onclick={() => bulkAction.onClick(selectedIds!)}- disabled={bulkAction.disabled || bulkAction.loading}- loading={bulkAction.loading}- title={bulkAction.disabled ? bulkAction.disabledReason : undefined}- class="h-9"- />+ <ArcaneTooltip.Root>+ <ArcaneTooltip.Trigger>+ {#snippet child({ props })}+ <ArcaneButton+ {...props}+ action={actionType}+ size="icon"+ icon={bulkAction.icon}+ customLabel={bulkAction.label}+ onclick={() => bulkAction.onClick(selectedIds!)}+ disabled={bulkAction.disabled || bulkAction.loading}+ loading={bulkAction.loading}+ title={bulkAction.disabled ? bulkAction.disabledReason : undefined}+ />+ {/snippet}+ </ArcaneTooltip.Trigger>+ <ArcaneTooltip.Content side="bottom">+ {bulkAction.label}+ </ArcaneTooltip.Content>+ </ArcaneTooltip.Root>{/each}</div>{/if}diff --git a/frontend/src/lib/components/dialogs/version-info-dialog.svelte b/frontend/src/lib/components/dialogs/version-info-dialog.svelteindex 215c767ce..802fe5cde 100644--- a/frontend/src/lib/components/dialogs/version-info-dialog.svelte+++ b/frontend/src/lib/components/dialogs/version-info-dialog.svelte@@ -1,12 +1,18 @@<script lang="ts">import { ResponsiveDialog } from '#lib/components/ui/responsive-dialog/index.js';import { ArcaneButton } from '#lib/components/arcane-button/index.js';- import type { AppVersionInformation } from '#lib/types/settings';+ import { Switch } from '#lib/components/ui/switch/index.js';+ import type { AppVersionInformation, Settings } from '#lib/types/settings';import { m } from '#lib/paraglide/messages';import { CopyButton } from '#lib/components/ui/copy-button';import { getApplicationLogo } from '#lib/utils/docker';import { accentColorPreviewStore } from '#lib/utils/theme';import { ExternalLinkIcon, GithubIcon, BookOpenIcon } from '#lib/icons';+ import { hasPermission } from '#lib/utils/auth';+ import settingsStore from '#lib/stores/config-store';+ import { settingsService } from '#lib/services/settings-service';+ import { handleApiResultWithCallbacks, tryCatch } from '#lib/utils/api';+ import { toast } from 'svelte-sonner';interface Props {open: boolean;@@ -36,6 +42,22 @@const enabledFeatures = $derived((displayInfo.enabledFeatures ?? []).filter(Boolean).join(', '));const accentColor = $derived($accentColorPreviewStore);const logoUrl = $derived(getApplicationLogo(false, accentColor, accentColor));++ const canToggleExperimental = $derived(hasPermission('settings:write'));+ const experimentalEnabled = $derived($settingsStore?.experimentalFeaturesEnabled === true);+ let savingExperimental = $state(false);++ async function handleExperimentalToggle(enabled: boolean) {+ handleApiResultWithCallbacks<Settings>({+ result: await tryCatch(settingsService.updateSettings({ experimentalFeaturesEnabled: enabled })),+ message: m.common_update_failed({ resource: m.settings() }),+ setLoadingState: (value) => (savingExperimental = value),+ onSuccess: async (updated) => {+ settingsStore.set(updated);+ toast.success(m.common_update_success({ resource: m.settings() }));+ }+ });+ }</script><ResponsiveDialog {open} {onOpenChange} contentClass="sm:max-w-md">@@ -70,6 +92,22 @@{@render infoRow(m.version_info_build_features(), enabledFeatures || '-')}+ {#if canToggleExperimental}+ <div class="flex items-center justify-between gap-3 border-b border-border/50 py-3 last:border-0">+ <div class="flex flex-col gap-1">+ <span class="text-sm font-medium text-foreground">{m.experimental_features()}</span>+ <span class="text-sm text-muted-foreground">{m.experimental_features_description()}</span>+ </div>+ <Switch+ id="experimental-features-toggle"+ checked={experimentalEnabled}+ disabled={savingExperimental}+ aria-label={m.experimental_features()}+ onCheckedChange={handleExperimentalToggle}+ />+ </div>+ {/if}+{#if displayInfo.currentDigest}{@render infoRowWithCopy(m.version_info_digest(), displayInfo.currentDigest, displayInfo.currentDigest)}{/if}diff --git a/frontend/src/lib/services/container-service.ts b/frontend/src/lib/services/container-service.tsindex c612d4e66..81c6a46a3 100644--- a/frontend/src/lib/services/container-service.ts+++ b/frontend/src/lib/services/container-service.ts@@ -104,8 +104,11 @@ class ContainerService extends BaseAPIService {return this.handleResponse(this.api.post(`/environments/${envId}/containers/${containerId}/commit`, request));}- async deleteContainer(containerId: string, opts?: { force?: boolean; volumes?: boolean }): Promise<any> {- const envId = await environmentStore.getCurrentEnvironmentId();+ async deleteContainer(+ containerId: string,+ opts?: { force?: boolean; volumes?: boolean; environmentId?: string }+ ): Promise<any> {+ const envId = await this.resolveEnvironmentId(opts?.environmentId);const params: Record<string, string> = {};if (opts?.force !== undefined) params['force'] = String(!!opts.force);if (opts?.volumes !== undefined) params['volumes'] = String(!!opts.volumes);@@ -123,6 +126,11 @@ class ContainerService extends BaseAPIService {return this.handleResponse(this.api.post(`/environments/${envId}/containers/${containerId}/redeploy`));}+ async generateCompose(containerIds: string[], environmentId?: string): Promise<{ composeContent: string }> {+ const envId = await this.resolveEnvironmentId(environmentId);+ return this.handleResponse(this.api.post(`/environments/${envId}/containers/generate-compose`, { containerIds }));+ }+async getContainerEditConfig(containerId: string, environmentId?: string): Promise<ContainerEditConfigDto> {const envId = await this.resolveEnvironmentId(environmentId);return this.handleResponse(this.api.get(`/environments/${envId}/containers/${containerId}/edit-config`));diff --git a/frontend/src/lib/types/settings.ts b/frontend/src/lib/types/settings.tsindex 2058bf770..36a7ebbda 100644--- a/frontend/src/lib/types/settings.ts+++ b/frontend/src/lib/types/settings.ts@@ -54,6 +54,7 @@ export type Settings = {gitSyncMaxBinarySizeMb: number;baseServerUrl: string;enableGravatar: boolean;+ experimentalFeaturesEnabled: boolean;avatarMaxUploadSizeMb: number;uiConfigDisabled: boolean;defaultShell: string;diff --git a/frontend/src/lib/utils/settings.ts b/frontend/src/lib/utils/settings.tsindex cfd1566eb..e821209de 100644--- a/frontend/src/lib/utils/settings.ts+++ b/frontend/src/lib/utils/settings.ts@@ -6,6 +6,7 @@ import { z } from 'zod/v4';export type LocalSettings = {edgeMTLSManagerCAAvailable?: boolean;avatarMaxUploadSizeMb: number;+ experimentalFeaturesEnabled?: boolean;};const LOCAL_SETTING_KEYS = new Set([@@ -25,7 +26,8 @@ const LOCAL_SETTING_KEYS = new Set(['oidcGroupsClaim','oidcProviderName','oidcProviderLogoUrl',- 'edgeMTLSManagerCAAvailable'+ 'edgeMTLSManagerCAAvailable',+ 'experimentalFeaturesEnabled']);export function isLocalSetting(key: string): boolean {diff --git a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte b/frontend/src/routes/(app)/containers/[containerId]/+page.svelteindex 071d514a0..fc53adbd0 100644--- a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte+++ b/frontend/src/routes/(app)/containers/[containerId]/+page.svelte@@ -1,6 +1,7 @@<script lang="ts">import { ArcaneButton } from '#lib/components/arcane-button/index.js';- import { refreshAll } from '$app/navigation';+ import { goto, refreshAll } from '$app/navigation';+ import settingsStore from '#lib/stores/config-store';import ActionButtons from '#lib/components/action-buttons.svelte';import { Badge } from '#lib/components/ui/badge';import { bytes } from '#lib/utils/formatting';@@ -46,7 +47,7 @@import { environmentStore } from '#lib/stores/environment.store.svelte';import { hasPermission } from '#lib/utils/auth';import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';- import { EditIcon, ImagesIcon, PauseIcon, PlayIcon, UpdateIcon, ZapIcon } from '#lib/icons';+ import { EditIcon, ImagesIcon, PauseIcon, PlayIcon, ProjectsIcon, UpdateIcon, ZapIcon } from '#lib/icons';import { runContainerLifecycleAction, confirmAndUpdateContainer } from '#lib/utils/container-actions';import { imageService } from '#lib/services/image-service';import type { ImageUpdateInfoDto } from '#lib/types/docker';@@ -141,6 +142,11 @@);const canKillContainer = $derived(hasPermission('containers:kill', currentEnvId));const canCommitImage = $derived(hasPermission('images:commit', currentEnvId));+ const canConvertToCompose = $derived(+ hasPermission('projects:create', currentEnvId) &&+ !container?.composeInfo &&+ $settingsStore?.experimentalFeaturesEnabled === true+ );const containerStatus = $derived(container?.state?.status ?? '');const isContainerRunning = $derived(containerStatus === 'running' || !!container?.state?.running);const isContainerPaused = $derived(containerStatus === 'paused');@@ -387,6 +393,17 @@href={`/containers/${container.id}/edit`}/>{/if}+ {#if canConvertToCompose}+ <ArcaneButton+ action="base"+ {size}+ {showLabel}+ customLabel={m.compose_convert_action()}+ icon={ProjectsIcon}+ disabled={actionButtonsLifecyclePending}+ href={`/projects/new?fromContainers=${container.id}&fromEnv=${encodeURIComponent(currentEnvId)}`}+ />+ {/if}{#if canUpdateContainer && updateInfo?.hasUpdate}<ArcaneButtonaction="base"@@ -439,6 +456,15 @@{/snippet}{#snippet beforeRemoveMenuItems(actionButtonsLifecyclePending)}+ {#if canConvertToCompose}+ <DropdownMenu.Item+ disabled={actionButtonsLifecyclePending}+ onclick={() => goto(`/projects/new?fromContainers=${container.id}&fromEnv=${encodeURIComponent(currentEnvId)}`)}+ >+ <ProjectsIcon class="size-4" />+ {m.compose_convert_action()}+ </DropdownMenu.Item>+ {/if}{#if canUpdateContainer && updateInfo?.hasUpdate}<DropdownMenu.Item disabled={updateLoading || actionButtonsLifecyclePending} onclick={handleUpdateContainer}><UpdateIcon class="size-4" />diff --git a/frontend/src/routes/(app)/containers/container-table.svelte b/frontend/src/routes/(app)/containers/container-table.svelteindex 708fdb4f7..327a4c323 100644--- a/frontend/src/routes/(app)/containers/container-table.svelte+++ b/frontend/src/routes/(app)/containers/container-table.svelte@@ -34,6 +34,7 @@import { hasAnyLoadingState } from '#lib/utils/bulk-actions';import { Temporal } from 'temporal-polyfill';import { createContainerActions } from './container-table.actions';+ import settingsStore from '#lib/stores/config-store';import {getActionStatusMessage,getContainerDisplayName,@@ -195,6 +196,18 @@const canEditContainers = $derived(hasPermission('containers:edit', currentEnvId));const canKillContainers = $derived(hasPermission('containers:kill', currentEnvId));const canPauseContainers = $derived(hasPermission('containers:pause', currentEnvId));+ const canConvertToCompose = $derived(+ hasPermission('projects:create', currentEnvId) && $settingsStore?.experimentalFeaturesEnabled === true+ );++ function handleBulkConvert(ids: string[]) {+ const convertibleIds = ids.filter((id) => {+ const container = containers.data?.find((c) => c.id === id);+ return container && !container.labels?.[COMPOSE_PROJECT_LABEL];+ });+ if (convertibleIds.length === 0) return;+ goto(`/projects/new?fromContainers=${convertibleIds.join(',')}&fromEnv=${encodeURIComponent(currentEnvId)}`);+ }// The dialog is mounted only while a row is targeted, so it gets fresh state on// every open; clearing the target unmounts it.@@ -338,7 +351,19 @@loading: isBulkLoading.remove,disabled: !resourcesCurrent || isAnyLoading,icon: TrashIcon- }+ },+ ...(canConvertToCompose+ ? [+ {+ id: 'convert',+ label: m.containers_bulk_convert({ count: selectedIds?.length ?? 0 }),+ action: 'base' as const,+ onClick: handleBulkConvert,+ disabled: !resourcesCurrent || isAnyLoading,+ icon: ProjectsIcon+ }+ ]+ : [])]);// Icon for each group@@ -644,6 +669,16 @@</DropdownMenu.Item>{/if}+ {#if canConvertToCompose && !item.labels?.[COMPOSE_PROJECT_LABEL]}+ <DropdownMenu.Item+ onclick={() => goto(`/projects/new?fromContainers=${item.id}&fromEnv=${encodeURIComponent(currentEnvId)}`)}+ disabled={isAnyLoading}+ >+ <ProjectsIcon class="size-4" />+ {m.compose_convert_action()}+ </DropdownMenu.Item>+ {/if}+<DropdownMenu.Separator />{#if item.updateInfo?.hasUpdate && canUpdateContainers}diff --git a/frontend/src/routes/(app)/projects/new/+page.svelte b/frontend/src/routes/(app)/projects/new/+page.svelteindex 4b57bf5b4..ab6fd99b6 100644--- a/frontend/src/routes/(app)/projects/new/+page.svelte+++ b/frontend/src/routes/(app)/projects/new/+page.svelte@@ -15,6 +15,9 @@import EditorTabStrip from '#lib/components/editor-tab-strip.svelte';import { environmentStore } from '#lib/stores/environment.store.svelte';import { hasPermission } from '#lib/utils/auth';+ import { containerService } from '#lib/services/container-service';+ import { openConfirmDialog } from '#lib/components/confirm-dialog';+ import { extractApiErrorMessage, tryCatch } from '#lib/utils/api';import { ComposeEditorSplit } from '#lib/components/compose';import ResizableSplit from '#lib/components/resizable-split.svelte';import { Switch } from '#lib/components/ui/switch';@@ -63,6 +66,8 @@const currentEnvId = $derived(environmentStore.selected?.id || '0');const canCreateProject = $derived(hasPermission('projects:create', currentEnvId));+ const canDeleteContainers = $derived(hasPermission('containers:delete', currentEnvId));+ const sourceContainerIds = $derived(data.sourceContainerIds ?? []);const projectWorkspaceMaxFileSizeMb = $derived($settingsStore?.projectWorkspaceMaxFileSizeMb ?? 10);let ui = $state({@@ -79,7 +84,11 @@// Initial form values intentionally come from the page load data once.// svelte-ignore state_referenced_locallyconst formData = {- name: data.selectedTemplate ? templateNameSlug(data.selectedTemplate.name) : '',+ name: data.selectedTemplate+ ? templateNameSlug(data.selectedTemplate.name)+ : data.sourceContainerName+ ? templateNameSlug(data.sourceContainerName)+ : '',composeContent: data.defaultTemplate || '',envContent: data.envTemplate || ''};@@ -192,10 +201,23 @@const effectiveName = $derived(composeYamlName ?? $inputs.name.value);async function handleSubmit() {- await handleCreateProject();+ if (sourceContainerIds.length > 0 && canDeleteContainers) {+ openConfirmDialog({+ title: m.compose_create_project(),+ message: m.convert_create_message(),+ confirm: {+ label: m.compose_create_project(),+ button: 'create',+ action: (checkboxStates) => handleCreateProject(!!checkboxStates['removeOriginals'])+ },+ checkboxes: [{ id: 'removeOriginals', label: m.remove_original_containers() }]+ });+ return;+ }+ await handleCreateProject(false);}- async function handleCreateProject() {+ async function handleCreateProject(removeOriginals: boolean) {// Sync the authoritative compose name into form state at submit time so// validation and the create payload use it (event-time write, not an effect).if (composeYamlName) form.setValue('name', composeYamlName);@@ -210,6 +232,17 @@m.common_create_success({ resource: `${m.resource_project()} "${name}"` }),activityToastOptions(extractActivityId(project)));+ if (removeOriginals && canDeleteContainers) {+ for (const containerId of sourceContainerIds) {+ const { error } = await tryCatch(+ containerService.deleteContainer(containerId, {+ force: true,+ environmentId: data.sourceEnvironmentId+ })+ );+ if (error) toast.error(m.containers_remove_failed(), { description: extractApiErrorMessage(error) });+ }+ }// fallow-ignore-next-line code-duplication -- create-success handler; navigation target diverges per pagegoto(`/projects/${project.id}`, { refreshAll: true });}diff --git a/frontend/src/routes/(app)/projects/new/+page.ts b/frontend/src/routes/(app)/projects/new/+page.tsindex a41c823d3..aabd0ef90 100644--- a/frontend/src/routes/(app)/projects/new/+page.ts+++ b/frontend/src/routes/(app)/projects/new/+page.ts@@ -1,11 +1,28 @@+import { parse } from 'yaml';+import { containerService } from '#lib/services/container-service';+import { throwPageLoadError, tryCatch } from '#lib/utils/api';import { loadTemplateAuthoringData, loadTemplateContent } from '#lib/utils/template-load';import type { PageLoad } from './$types';+async function generateFromContainers(ids: string[], environmentId?: string) {+ const { data, error } = await tryCatch(containerService.generateCompose(ids, environmentId));+ if (error) throwPageLoadError(error, 'Failed to generate compose file from containers');++ const parsed = await tryCatch(Promise.resolve(data.composeContent).then(parse));+ return { composeContent: data.composeContent, name: Object.keys(parsed.data?.services ?? {})[0] ?? '' };+}+export const load: PageLoad = async ({ url, parent }) => {const { queryClient } = await parent();const templateId = url.searchParams.get('templateId');- const { defaultTemplates, templates: allTemplates, globalVariables } = await loadTemplateAuthoringData(parent);+ const sourceContainerIds = url.searchParams.get('fromContainers')?.split(',').filter(Boolean) ?? [];+ const sourceEnvironmentId = url.searchParams.get('fromEnv') || undefined;++ const [{ defaultTemplates, templates: allTemplates, globalVariables }, generated] = await Promise.all([+ loadTemplateAuthoringData(parent),+ sourceContainerIds.length ? generateFromContainers(sourceContainerIds, sourceEnvironmentId) : null+ ]);const selectedTemplate = templateId? await loadTemplateContent(queryClient as Parameters<typeof loadTemplateContent>[0], templateId)@@ -13,9 +30,12 @@ export const load: PageLoad = async ({ url, parent }) => {return {composeTemplates: allTemplates,- envTemplate: selectedTemplate?.envContent || defaultTemplates.envTemplate,- defaultTemplate: selectedTemplate?.content || defaultTemplates.composeTemplate,+ envTemplate: generated ? '' : selectedTemplate?.envContent || defaultTemplates.envTemplate,+ defaultTemplate: generated?.composeContent || selectedTemplate?.content || defaultTemplates.composeTemplate,selectedTemplate: selectedTemplate?.template || null,+ sourceContainerIds,+ sourceEnvironmentId,+ sourceContainerName: generated?.name ?? '',globalVariables};};diff --git a/types/container/container.go b/types/container/container.goindex d7e3eca5f..48ada04bd 100644--- a/types/container/container.go+++ b/types/container/container.go@@ -400,6 +400,16 @@ type CommitResult struct {ID string `json:"id"`}+// GenerateComposeRequest selects the containers to convert into a compose project.+type GenerateComposeRequest struct {+ ContainerIDs []string `json:"containerIds" minItems:"1" doc:"IDs of the containers to convert"`+}++// GenerateComposeResponse carries the compose file generated from containers.+type GenerateComposeResponse struct {+ ComposeContent string `json:"composeContent"`+}+// StatusCounts contains counts of containers by status.type StatusCounts struct {// RunningContainers is the number of running containers.diff --git a/types/settings/settings.go b/types/settings/settings.goindex 28a170b47..7cc232098 100644--- a/types/settings/settings.go+++ b/types/settings/settings.go@@ -241,6 +241,8 @@ type Update struct {// Required: falseAvatarMaxUploadSizeMb *string `json:"avatarMaxUploadSizeMb,omitempty"`+ ExperimentalFeaturesEnabled *string `json:"experimentalFeaturesEnabled,omitempty"`+// DefaultShell is the default shell used for container execution.//// Required: false