From 6b49d1323608b4d7d23038a2d06a4a9475ff617a Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 2 Feb 2026 23:46:47 -0800 Subject: [PATCH] Add option to pull image before container update --- src/routes/api/containers/[id]/update/+server.ts | 15 +++++++++++++-- src/routes/containers/ContainerSettingsTab.svelte | 7 +++++++ src/routes/containers/EditContainerModal.svelte | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) 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 @@ +