From 5d14b9209d69230a876884eb37b53066b770dc56 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 15 Feb 2022 19:13:50 +0100 Subject: [PATCH] fix: Coolify image cleanup --- src/lib/database/destinations.ts | 2 +- src/lib/queues/cleanup.ts | 4 ++-- src/lib/queues/proxy.ts | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/database/destinations.ts b/src/lib/database/destinations.ts index 884600bfe..b566becb4 100644 --- a/src/lib/database/destinations.ts +++ b/src/lib/database/destinations.ts @@ -38,7 +38,7 @@ export async function configureDestinationForDatabase({ id, destinationId }) { if (type && version) { const baseImage = getDatabaseImage(type); asyncExecShell( - `DOCKER_HOST=${host} docker pull ${baseImage}:${version} && echo "FROM ${baseImage}:${version}" | docker build --label coolify.managed="true" -t "${baseImage}:${version}" -` + `DOCKER_HOST=${host} docker pull ${baseImage}:${version} && echo "FROM ${baseImage}:${version}" | docker build --label coolify.image="true" -t "${baseImage}:${version}" -` ); } } diff --git a/src/lib/queues/cleanup.ts b/src/lib/queues/cleanup.ts index e7bd31e1f..cb8939bda 100644 --- a/src/lib/queues/cleanup.ts +++ b/src/lib/queues/cleanup.ts @@ -23,7 +23,7 @@ export default async function () { ]; for (const image of images) { await asyncExecShell( - `DOCKER_HOST=${host} docker pull ${image} && echo "FROM ${image}" | docker build --label coolify.managed="true" -t "${image}" -` + `DOCKER_HOST=${host} docker pull ${image} && echo "FROM ${image}" | docker build --label coolify.image="true" -t "${image}" -` ); } } catch (error) {} @@ -35,7 +35,7 @@ export default async function () { // Cleanup images that are not managed by coolify try { await asyncExecShell( - `DOCKER_HOST=${host} docker image prune --filter 'label!=coolify.managed=true' -a -f` + `DOCKER_HOST=${host} docker image prune --filter 'label!=coolify.image=true' -a -f` ); } catch (error) { console.log(error); diff --git a/src/lib/queues/proxy.ts b/src/lib/queues/proxy.ts index 7a894d446..ea7b3c142 100644 --- a/src/lib/queues/proxy.ts +++ b/src/lib/queues/proxy.ts @@ -27,7 +27,10 @@ export default async function () { const parsedConfiguration = JSON.parse( Buffer.from(configuration.Labels['coolify.configuration'], 'base64').toString() ); - if (configuration.Labels['coolify.type'] === 'standalone-application') { + if ( + parsedConfiguration && + configuration.Labels['coolify.type'] === 'standalone-application' + ) { const { fqdn, applicationId, port, pullmergeRequestId } = parsedConfiguration; if (fqdn) { const found = await getApplicationById({ id: applicationId });