Enhance compose removal process by adding network disconnection command

- Updated the `removeCompose` function to include a command for disconnecting the Docker network before removing the stack or compose application, improving cleanup reliability.
- Removed unnecessary console logging in the `getServiceImageDigest` function to streamline output and enhance code clarity.
This commit is contained in:
Mauricio Siu 2025-05-04 16:50:03 -06:00
parent 9948dd7f19
commit eb5ba2f219
2 changed files with 8 additions and 9 deletions

View File

@ -478,7 +478,9 @@ export const removeCompose = async (
const projectPath = join(COMPOSE_PATH, compose.appName); const projectPath = join(COMPOSE_PATH, compose.appName);
if (compose.composeType === "stack") { if (compose.composeType === "stack") {
const command = `cd ${projectPath} && docker stack rm ${compose.appName} && rm -rf ${projectPath}`; const command = `
docker network disconnect ${compose.appName} dokploy-traefik;
cd ${projectPath} && docker stack rm ${compose.appName} && rm -rf ${projectPath}`;
if (compose.serverId) { if (compose.serverId) {
await execAsyncRemote(compose.serverId, command); await execAsyncRemote(compose.serverId, command);
@ -489,12 +491,11 @@ export const removeCompose = async (
cwd: projectPath, cwd: projectPath,
}); });
} else { } else {
let command: string; const command = `
if (deleteVolumes) { docker network disconnect ${compose.appName} dokploy-traefik;
command = `cd ${projectPath} && docker compose -p ${compose.appName} down --volumes && rm -rf ${projectPath}`; cd ${projectPath} && docker compose -p ${compose.appName} down ${
} else { deleteVolumes ? "--volumes" : ""
command = `cd ${projectPath} && docker compose -p ${compose.appName} down && rm -rf ${projectPath}`; } && rm -rf ${projectPath}`;
}
if (compose.serverId) { if (compose.serverId) {
await execAsyncRemote(compose.serverId, command); await execAsyncRemote(compose.serverId, command);

View File

@ -40,8 +40,6 @@ export const getServiceImageDigest = async () => {
"docker service inspect dokploy --format '{{.Spec.TaskTemplate.ContainerSpec.Image}}'", "docker service inspect dokploy --format '{{.Spec.TaskTemplate.ContainerSpec.Image}}'",
); );
console.log("stdout", stdout);
const currentDigest = stdout.trim().split("@")[1]; const currentDigest = stdout.trim().split("@")[1];
if (!currentDigest) { if (!currentDigest) {