fix: Cleanup images
This commit is contained in:
@@ -8,6 +8,8 @@ RUN yarn build
|
|||||||
FROM node:16.14.0-alpine
|
FROM node:16.14.0-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
LABEL coolify.managed true
|
||||||
|
|
||||||
RUN apk add --no-cache git openssh-client curl jq cmake sqlite
|
RUN apk add --no-cache git openssh-client curl jq cmake sqlite
|
||||||
|
|
||||||
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
|
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
|
||||||
|
@@ -37,11 +37,9 @@ export async function configureDestinationForDatabase({ id, destinationId }) {
|
|||||||
const host = getEngine(engine);
|
const host = getEngine(engine);
|
||||||
if (type && version) {
|
if (type && version) {
|
||||||
const baseImage = getDatabaseImage(type);
|
const baseImage = getDatabaseImage(type);
|
||||||
asyncExecShell(`DOCKER_HOST=${host} docker pull ${baseImage}:${version}`);
|
asyncExecShell(
|
||||||
asyncExecShell(`DOCKER_HOST=${host} docker pull coollabsio/${defaultProxyImageTcp}`);
|
`DOCKER_HOST=${host} docker pull ${baseImage}:${version} && echo "FROM ${baseImage}:${version}" | docker build --label coolify.managed="true" -t "${baseImage}:${version}" -`
|
||||||
asyncExecShell(`DOCKER_HOST=${host} docker pull coollabsio/${defaultProxyImageHttp}`);
|
);
|
||||||
asyncExecShell(`DOCKER_HOST=${host} docker pull certbot/certbot:latest`);
|
|
||||||
asyncExecShell(`DOCKER_HOST=${host} docker pull alpine:latest`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,22 +1,38 @@
|
|||||||
import { dev } from '$app/env';
|
import { dev } from '$app/env';
|
||||||
import { asyncExecShell, getEngine } from '$lib/common';
|
import { asyncExecShell, getEngine } from '$lib/common';
|
||||||
import { prisma } from '$lib/database';
|
import { prisma } from '$lib/database';
|
||||||
|
import { defaultProxyImageHttp, defaultProxyImageTcp } from '$lib/haproxy';
|
||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
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);
|
||||||
|
// Tagging images with labels
|
||||||
try {
|
try {
|
||||||
// await asyncExecShell(`DOCKER_HOST=${host} docker container prune -f`);
|
const images = [
|
||||||
|
`coollabsio/${defaultProxyImageTcp}`,
|
||||||
|
`coollabsio/${defaultProxyImageHttp}`,
|
||||||
|
'certbot/certbot:latest',
|
||||||
|
' alpine:latest'
|
||||||
|
];
|
||||||
|
for (const image of images) {
|
||||||
|
await asyncExecShell(
|
||||||
|
`DOCKER_HOST=${host} docker pull ${image} && echo "FROM ${image}" | docker build --label coolify.managed="true" -t "${image}" -`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {}
|
||||||
|
try {
|
||||||
|
await asyncExecShell(`DOCKER_HOST=${host} docker container prune -f`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//
|
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
// Cleanup images that are not managed by coolify
|
||||||
try {
|
try {
|
||||||
// await asyncExecShell(`DOCKER_HOST=${host} docker image prune -f`);
|
await asyncExecShell(
|
||||||
|
`DOCKER_HOST=${host} docker image prune --filter 'label!=coolify.managed=true' -a -f`
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//
|
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user