From 28f87a306dcf805d753c07642a604da19d7f3efc Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 12 Apr 2022 20:57:49 +0200 Subject: [PATCH] fix: Cleanup images older than a day --- src/lib/queues/cleanup.ts | 51 +++++++-------------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/src/lib/queues/cleanup.ts b/src/lib/queues/cleanup.ts index 3802e3317..05f795799 100644 --- a/src/lib/queues/cleanup.ts +++ b/src/lib/queues/cleanup.ts @@ -14,56 +14,23 @@ export default async function (): Promise { await asyncExecShell(`DOCKER_HOST=${host} docker rmi -f ${images}`); } } catch (error) { - console.log(error); + //console.log(error); } try { await asyncExecShell(`DOCKER_HOST=${host} docker container prune -f`); } catch (error) { - console.log(error); + //console.log(error); } try { await asyncExecShell(`DOCKER_HOST=${host} docker image prune -f --filter "until=2h"`); } catch (error) { - console.log(error); + //console.log(error); + } + // Cleanup old images older than a day + try { + await asyncExecShell(`DOCKER_HOST=${host} docker image prune --filter "until=24h" -a -f`); + } catch (error) { + //console.log(error); } - // Tagging images with labels - // try { - // const images = [ - // `coollabsio/${defaultProxyImageTcp}`, - // `coollabsio/${defaultProxyImageHttp}`, - // 'certbot/certbot:latest', - // 'node:16.14.0-alpine', - // 'alpine:latest', - // 'nginx:stable-alpine', - // 'node:lts', - // 'php:apache', - // 'rust:latest' - // ]; - // for (const image of images) { - // try { - // await asyncExecShell(`DOCKER_HOST=${host} docker image inspect ${image}`); - // } catch (error) { - // await asyncExecShell( - // `DOCKER_HOST=${host} docker pull ${image} && echo "FROM ${image}" | docker build --label coolify.image="true" -t "${image}" -` - // ); - // } - // } - // } catch (error) {} - // if (!dev) { - // // Cleanup images that are not managed by coolify - // try { - // await asyncExecShell( - // `DOCKER_HOST=${host} docker image prune --filter 'label!=coolify.image=true' -a -f` - // ); - // } catch (error) { - // console.log(error); - // } - // // Cleanup old images >3 days - // try { - // await asyncExecShell(`DOCKER_HOST=${host} docker image prune --filter "until=72h" -a -f`); - // } catch (error) { - // console.log(error); - // } - // } } }