cleanup old images of coolify

This commit is contained in:
Andras Bacsai
2022-03-02 14:53:43 +01:00
parent d9fcaf3473
commit 3d27fd04ba

View File

@@ -1,12 +1,28 @@
import { dev } from '$app/env'; import { dev } from '$app/env';
import { asyncExecShell, getEngine } from '$lib/common'; import { asyncExecShell, getEngine, version } from '$lib/common';
import { prisma } from '$lib/database'; import { prisma } from '$lib/database';
import { defaultProxyImageHttp, defaultProxyImageTcp } from '$lib/haproxy'; import { defaultProxyImageHttp, defaultProxyImageTcp } from '$lib/haproxy';
export default async function () { export default async function () {
const destinationDockers = await prisma.destinationDocker.findMany(); const destinationDockers = await prisma.destinationDocker.findMany();
for (const destinationDocker of destinationDockers) { for (const destinationDocker of destinationDockers) {
const host = getEngine(destinationDocker.engine); 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 // Tagging images with labels
// try { // try {
// const images = [ // const images = [
@@ -30,16 +46,6 @@ export default async function () {
// } // }
// } // }
// } catch (error) {} // } 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) { // if (!dev) {
// // Cleanup images that are not managed by coolify // // Cleanup images that are not managed by coolify
// try { // try {