mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-16 08:55:18 +00:00
[BUG] fix: volume cleaning should not be performed
This commit is contained in:
@@ -174,9 +174,9 @@ echo "Execution completed."`;
|
|||||||
const cleanupCommands = {
|
const cleanupCommands = {
|
||||||
containers: "docker container prune --force",
|
containers: "docker container prune --force",
|
||||||
images: "docker image prune --all --force",
|
images: "docker image prune --all --force",
|
||||||
|
volumes: "docker volume prune --all --force",
|
||||||
builders: "docker builder prune --all --force",
|
builders: "docker builder prune --all --force",
|
||||||
system: "docker system prune --all --force",
|
system: "docker system prune --all --force",
|
||||||
volumes: "docker volume prune --all --force",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const cleanupContainers = async (serverId?: string) => {
|
export const cleanupContainers = async (serverId?: string) => {
|
||||||
@@ -257,24 +257,40 @@ export const cleanupSystem = async (serverId?: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Volume cleanup should always be performed manually by the user. The reason is that during automatic cleanup, a volume may be deleted due to a stopped container, which is a dangerous situation.
|
||||||
|
*
|
||||||
|
* https://github.com/Dokploy/dokploy/pull/3266
|
||||||
|
*/
|
||||||
|
const excludedCleanupAllCommands: (keyof typeof cleanupCommands)[] = ['volumes'];
|
||||||
|
|
||||||
export const cleanupAll = async (serverId?: string) => {
|
export const cleanupAll = async (serverId?: string) => {
|
||||||
await cleanupContainers(serverId);
|
for (const [key, command] of Object.entries(cleanupCommands)) {
|
||||||
await cleanupImages(serverId);
|
if (excludedCleanupAllCommands.includes(key)) continue;
|
||||||
await cleanupBuilders(serverId);
|
|
||||||
await cleanupSystem(serverId);
|
try {
|
||||||
|
if (serverId) {
|
||||||
|
await execAsyncRemote(serverId, dockerSafeExec(command));
|
||||||
|
} else {
|
||||||
|
await execAsync(dockerSafeExec(command));
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const cleanupAllBackground = async (serverId?: string) => {
|
export const cleanupAllBackground = async (serverId?: string) => {
|
||||||
Promise.allSettled(
|
Promise.allSettled(
|
||||||
Object.values(cleanupCommands).map(async (command) => {
|
Object.entries(cleanupCommands)
|
||||||
try {
|
.filter(([key]) => !excludedCleanupAllCommands.includes(key))
|
||||||
if (serverId) {
|
.map(async ([, command]) => {
|
||||||
await execAsyncRemote(serverId, dockerSafeExec(command));
|
try {
|
||||||
} else {
|
if (serverId) {
|
||||||
await execAsync(dockerSafeExec(command));
|
await execAsyncRemote(serverId, dockerSafeExec(command));
|
||||||
}
|
} else {
|
||||||
} catch (error) {}
|
await execAsync(dockerSafeExec(command));
|
||||||
}),
|
}
|
||||||
|
} catch {}
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
const failed = results.filter((r) => r.status === "rejected");
|
const failed = results.filter((r) => r.status === "rejected");
|
||||||
|
|||||||
Reference in New Issue
Block a user