From 3d27fd04ba309f69182750b7d25f133c0cb374a9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <andras.bacsai@gmail.com> Date: Wed, 2 Mar 2022 14:53:43 +0100 Subject: [PATCH] cleanup old images of coolify --- src/lib/queues/cleanup.ts | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/lib/queues/cleanup.ts b/src/lib/queues/cleanup.ts index 53c1896a7..5a338c63f 100644 --- a/src/lib/queues/cleanup.ts +++ b/src/lib/queues/cleanup.ts @@ -1,12 +1,28 @@ import { dev } from '$app/env'; -import { asyncExecShell, getEngine } from '$lib/common'; +import { asyncExecShell, getEngine, version } from '$lib/common'; import { prisma } from '$lib/database'; import { defaultProxyImageHttp, defaultProxyImageTcp } from '$lib/haproxy'; - export default async function () { const destinationDockers = await prisma.destinationDocker.findMany(); for (const destinationDocker of destinationDockers) { const host = getEngine(destinationDocker.engine); + try { + await asyncExecShell( + `DOCKER_HOST=${host} docker rmi $(docker images coollabsio/coolify --filter before="coollabsio/coolify:latest" -q)` + ); + } catch (error) { + console.log(error); + } + try { + await asyncExecShell(`DOCKER_HOST=${host} docker container prune -f`); + } catch (error) { + console.log(error); + } + try { + await asyncExecShell(`DOCKER_HOST=${host} docker image prune -f`); + } catch (error) { + console.log(error); + } // Tagging images with labels // try { // const images = [ @@ -30,16 +46,6 @@ export default async function () { // } // } // } catch (error) {} - try { - await asyncExecShell(`DOCKER_HOST=${host} docker container prune -f`); - } catch (error) { - console.log(error); - } - try { - await asyncExecShell(`DOCKER_HOST=${host} docker image prune -f`); - } catch (error) { - console.log(error); - } // if (!dev) { // // Cleanup images that are not managed by coolify // try {