diff --git a/src/routes/api/containers/[id]/update/+server.ts b/src/routes/api/containers/[id]/update/+server.ts index 7bfe4ae..775c114 100644 --- a/src/routes/api/containers/[id]/update/+server.ts +++ b/src/routes/api/containers/[id]/update/+server.ts @@ -1,5 +1,5 @@ import { json } from '@sveltejs/kit'; -import { updateContainer, type CreateContainerOptions } from '$lib/server/docker'; +import { pullImage, updateContainer, type CreateContainerOptions } from '$lib/server/docker'; import { authorize } from '$lib/server/authorize'; import { auditContainer } from '$lib/server/audit'; import { removePendingContainerUpdate } from '$lib/server/db'; @@ -19,7 +19,18 @@ export const POST: RequestHandler = async (event) => { try { const body = await request.json(); - const { startAfterUpdate, ...options } = body; + const { startAfterUpdate, repullImage, ...options } = body; + + if (repullImage) { + console.log(`Pulling image...`); + try { + await pullImage(options.image, undefined, envIdNum); + console.log(`Image pulled successfully`); + } catch (pullError: any) { + console.log(`Pull failed: ${pullError.message}`); + throw pullError; + } + } console.log(`Updating container ${params.id} with name: ${options.name}`); diff --git a/src/routes/containers/ContainerSettingsTab.svelte b/src/routes/containers/ContainerSettingsTab.svelte index 94c6702..e9621b1 100644 --- a/src/routes/containers/ContainerSettingsTab.svelte +++ b/src/routes/containers/ContainerSettingsTab.svelte @@ -70,6 +70,7 @@ restartMaxRetries: number | ''; networkMode: string; startAfterCreate?: boolean; + repullImage?: boolean; // Port mappings portMappings: { hostPort: string; containerPort: string; protocol: string }[]; // Volume mappings @@ -152,6 +153,7 @@ restartMaxRetries = $bindable(), networkMode = $bindable(), startAfterCreate = $bindable(true), + repullImage = $bindable(true), portMappings = $bindable(), volumeMappings = $bindable(), envVars = $bindable(), @@ -643,6 +645,11 @@ +
+ + +
+
diff --git a/src/routes/containers/EditContainerModal.svelte b/src/routes/containers/EditContainerModal.svelte index 5ffe6c3..2025ca4 100644 --- a/src/routes/containers/EditContainerModal.svelte +++ b/src/routes/containers/EditContainerModal.svelte @@ -87,6 +87,7 @@ let restartMaxRetries = $state(''); let networkMode = $state('bridge'); let startAfterUpdate = $state(true); + let repullImage = $state(true); // Port mappings let portMappings = $state<{ hostPort: string; containerPort: string; protocol: string }[]>([ @@ -894,6 +895,7 @@ networkMode, networks: selectedNetworks.length > 0 ? selectedNetworks : undefined, startAfterUpdate, + repullImage, user: containerUser.trim() || undefined, privileged: privilegedMode || undefined, healthcheck, @@ -1055,6 +1057,7 @@ bind:restartMaxRetries bind:networkMode startAfterCreate={startAfterUpdate} + {repullImage} bind:portMappings bind:volumeMappings bind:envVars