fix: Coolify image cleanup

This commit is contained in:
Andras Bacsai
2022-02-15 19:13:50 +01:00
parent 305a95fa74
commit 5d14b9209d
3 changed files with 7 additions and 4 deletions

View File

@@ -38,7 +38,7 @@ export async function configureDestinationForDatabase({ id, destinationId }) {
if (type && version) { if (type && version) {
const baseImage = getDatabaseImage(type); const baseImage = getDatabaseImage(type);
asyncExecShell( 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}" -`
); );
} }
} }

View File

@@ -23,7 +23,7 @@ export default async function () {
]; ];
for (const image of images) { for (const image of images) {
await asyncExecShell( 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) {} } catch (error) {}
@@ -35,7 +35,7 @@ export default async function () {
// Cleanup images that are not managed by coolify // Cleanup images that are not managed by coolify
try { try {
await asyncExecShell( 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) { } catch (error) {
console.log(error); console.log(error);

View File

@@ -27,7 +27,10 @@ export default async function () {
const parsedConfiguration = JSON.parse( const parsedConfiguration = JSON.parse(
Buffer.from(configuration.Labels['coolify.configuration'], 'base64').toString() 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; const { fqdn, applicationId, port, pullmergeRequestId } = parsedConfiguration;
if (fqdn) { if (fqdn) {
const found = await getApplicationById({ id: applicationId }); const found = await getApplicationById({ id: applicationId });