From 05fb07890316ed669b361bf53190741b1a1548f6 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Fri, 2 Jan 2026 13:24:42 +0100 Subject: [PATCH] Remove application fix --- src/core/server/application.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/core/server/application.ts b/src/core/server/application.ts index f203a12..f6224d7 100644 --- a/src/core/server/application.ts +++ b/src/core/server/application.ts @@ -103,9 +103,26 @@ export async function setEnv(appId: string, variables: EnvVariable[]) { } export async function removeApp(appId: string) { - const imageTag = `dockship/${appId}:latest`; - const image = docker.getImage(imageTag); - await image.remove(); const appPath = path.join(DATA_DIR, appId); + + const appMeta: Application = JSON.parse( + fs.readFileSync(path.join(appPath, "app.json")).toString() + ); + + appMeta.deployments.forEach(async (imgId) => { + // Remove containers + (await docker.listContainers({ all: true })) + .filter((con) => con.ImageID === imgId) + .forEach((con) => { + const container = docker.getContainer(con.Id); + container.stop(); + container.remove(); + }); + + // Remove image + const image = docker.getImage(imgId); + image.remove(); + }); + fs.rmSync(appPath, { recursive: true }); }