From f5714536967d10b8eecd392cfcc071f7f49d7c8e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 14 Apr 2022 18:45:42 +0200 Subject: [PATCH] fix: Better performance for cleanup images --- src/lib/queues/cleanup.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/queues/cleanup.ts b/src/lib/queues/cleanup.ts index 05f795799..d5dc49381 100644 --- a/src/lib/queues/cleanup.ts +++ b/src/lib/queues/cleanup.ts @@ -2,8 +2,9 @@ import { asyncExecShell, getEngine, version } from '$lib/common'; import { prisma } from '$lib/database'; export default async function (): Promise { const destinationDockers = await prisma.destinationDocker.findMany(); - for (const destinationDocker of destinationDockers) { - const host = getEngine(destinationDocker.engine); + const engines = [...new Set(destinationDockers.map(({ engine }) => engine))]; + for (const engine of engines) { + const host = getEngine(engine); // Cleanup old coolify images try { let { stdout: images } = await asyncExecShell( @@ -28,7 +29,7 @@ export default async function (): Promise { } // Cleanup old images older than a day try { - await asyncExecShell(`DOCKER_HOST=${host} docker image prune --filter "until=24h" -a -f`); + await asyncExecShell(`DOCKER_HOST=${host} docker image prune --filter "until=72h" -a -f`); } catch (error) { //console.log(error); }