From 144a73a10a7f498778905cd2ad795359a1f290e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Strausmann?= Date: Thu, 30 Jul 2026 19:16:14 +0000 Subject: [PATCH] fix(stacks): apply env override file on stop/down for git stacks (#1313) startStack and restartStack compute isGitStack and pass useOverrideFile accordingly, so executeLocalCompose writes .env.dockhand with the DB non-secret overrides before invoking docker compose. stopStack and downStack never set this option, so whenever a .env file exists in the stack's working directory (e.g. committed alongside compose.yaml in a git stack), the legacy shell-env fallback in executeLocalCompose is suppressed and .env.dockhand is never written or attached via --env-file. Any required variable that only exists as a Dockhand panel override then fails interpolation on stop/down, even though the same stack deploys and starts successfully. Mirror startStack/restartStack: compute isGitStack from the stack source and pass useOverrideFile through in both operations. --- src/lib/server/stacks.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/server/stacks.ts b/src/lib/server/stacks.ts index 7c92b7b..e7df13f 100644 --- a/src/lib/server/stacks.ts +++ b/src/lib/server/stacks.ts @@ -2212,9 +2212,13 @@ export async function stopStack( return fallback; } + // Check if this is a git stack - git stacks need useOverrideFile to write .env.dockhand + const source = await getStackSource(stackName, envId); + const isGitStack = source?.sourceType === 'git'; + const composeResult = await executeComposeCommand( 'stop', - { stackName, envId, workingDir: result.stackDir, composePath: result.composePath, envPath: result.envPath }, + { stackName, envId, workingDir: result.stackDir, composePath: result.composePath, envPath: result.envPath, useOverrideFile: isGitStack }, result.content!, result.nonSecretVars, result.secretVars @@ -2289,9 +2293,13 @@ export async function downStack( return withContainerFallback(stackName, envId, 'stop'); } + // Check if this is a git stack - git stacks need useOverrideFile to write .env.dockhand + const source = await getStackSource(stackName, envId); + const isGitStack = source?.sourceType === 'git'; + const composeResult = await executeComposeCommand( 'down', - { stackName, envId, removeVolumes, workingDir: result.stackDir, composePath: result.composePath, envPath: result.envPath }, + { stackName, envId, removeVolumes, workingDir: result.stackDir, composePath: result.composePath, envPath: result.envPath, useOverrideFile: isGitStack }, result.content!, result.nonSecretVars, result.secretVars