Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

cleanup old images of coolify

Andras Bacsai3d27fd04ba30
diff --git a/src/lib/queues/cleanup.ts b/src/lib/queues/cleanup.ts
index 53c1896a7c..5a338c63fb 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 {