From 972d621e7b5f45560e6b01580acc11a058cbf12c Mon Sep 17 00:00:00 2001 From: Yousif Date: Sun, 10 May 2026 15:20:07 +0300 Subject: [PATCH] Force a new build with no caching if --no-cache flag is passed to the compose stack --- src/lib/server/stacks.ts | 66 +++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/src/lib/server/stacks.ts b/src/lib/server/stacks.ts index 5cbf54c8..522e81d9 100644 --- a/src/lib/server/stacks.ts +++ b/src/lib/server/stacks.ts @@ -834,7 +834,7 @@ function findComposeOverrideFile(stackDir: string, composeFileName: string): str * @param customComposePath - Optional path to existing compose file (for imported stacks, skips writing) */ async function executeLocalCompose( - operation: 'up' | 'down' | 'stop' | 'start' | 'restart' | 'pull', + operation: 'up' | 'down' | 'stop' | 'start' | 'restart' | 'pull' | 'build', stackName: string, composeContent: string, dockerHost?: string, @@ -1043,8 +1043,7 @@ async function executeLocalCompose( case 'up': args.push('up', '-d', '--remove-orphans'); if (forceRecreate) args.push('--force-recreate'); - if (build) args.push('--build'); - if (build && noBuildCache) args.push('--no-cache'); + if (build && !noBuildCache) args.push('--build'); if (pullPolicy) args.push('--pull', pullPolicy); // If targeting a specific service, only update that service if (serviceName) { @@ -1071,6 +1070,14 @@ async function executeLocalCompose( args.push(serviceName); } break; + case 'build': + args.push('build'); + if (noBuildCache) args.push('--no-cache'); + if (pullPolicy) args.push('--pull'); + if (serviceName) { + args.push(serviceName); + } + break; } const commandStr = args.join(' '); @@ -1209,7 +1216,7 @@ async function executeLocalCompose( * @param secretVars - Secret environment variables (injected via shell env on Hawser, NEVER in .env) */ async function executeComposeViaHawser( - operation: 'up' | 'down' | 'stop' | 'start' | 'restart' | 'pull', + operation: 'up' | 'down' | 'stop' | 'start' | 'restart' | 'pull' | 'build', stackName: string, composeContent: string, envId: number, @@ -1359,7 +1366,7 @@ async function executeComposeViaHawser( * @param secretVars - Secret environment variables (from DB, injected via shell env) */ async function executeComposeCommand( - operation: 'up' | 'down' | 'stop' | 'start' | 'restart' | 'pull', + operation: 'up' | 'down' | 'stop' | 'start' | 'restart' | 'pull' | 'build', options: ComposeCommandOptions, composeContent: string, envVars?: Record, @@ -2315,24 +2322,41 @@ export async function deployStack(options: DeployStackOptions): Promise