refactor
This commit is contained in:
@@ -256,26 +256,5 @@ export default async function (job) {
|
||||
throw new Error(error);
|
||||
}
|
||||
saveBuildLog({ line: 'Proxy will be configured shortly.', buildId, applicationId });
|
||||
// try {
|
||||
// if (destinationDockerId && destinationDocker.isCoolifyProxyUsed) {
|
||||
// saveBuildLog({ line: 'Proxy configuration started!', buildId, applicationId });
|
||||
// await checkProxyConfigurations();
|
||||
// await configureProxyForApplication(domain, imageId, port);
|
||||
// if (isHttps) await letsEncrypt({ domain, id: applicationId });
|
||||
// await setWwwRedirection(fqdn);
|
||||
// await reloadHaproxy(destinationDocker.engine);
|
||||
// saveBuildLog({ line: 'Proxy configuration successful!', buildId, applicationId });
|
||||
// } else {
|
||||
// saveBuildLog({
|
||||
// line: 'Coolify Proxy is not configured for this destination. Nothing else to do.',
|
||||
// buildId,
|
||||
// applicationId
|
||||
// });
|
||||
// }
|
||||
// } catch (error) {
|
||||
// saveBuildLog({ line: error.stdout || error, buildId, applicationId });
|
||||
// sentry.captureException(error);
|
||||
// throw new Error(error);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,48 +8,53 @@ export default async function () {
|
||||
for (const destinationDocker of destinationDockers) {
|
||||
const host = getEngine(destinationDocker.engine);
|
||||
// Tagging images with labels
|
||||
try {
|
||||
const images = [
|
||||
`coollabsio/${defaultProxyImageTcp}`,
|
||||
`coollabsio/${defaultProxyImageHttp}`,
|
||||
'certbot/certbot:latest',
|
||||
'node:16.14.0-alpine',
|
||||
'alpine:latest',
|
||||
'nginx:stable-alpine',
|
||||
'node:lts',
|
||||
'php:apache',
|
||||
'rust:latest'
|
||||
];
|
||||
for (const image of images) {
|
||||
try {
|
||||
await asyncExecShell(`DOCKER_HOST=${host} docker image inspect ${image}`);
|
||||
} catch (error) {
|
||||
await asyncExecShell(
|
||||
`DOCKER_HOST=${host} docker pull ${image} && echo "FROM ${image}" | docker build --label coolify.image="true" -t "${image}" -`
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {}
|
||||
// try {
|
||||
// const images = [
|
||||
// `coollabsio/${defaultProxyImageTcp}`,
|
||||
// `coollabsio/${defaultProxyImageHttp}`,
|
||||
// 'certbot/certbot:latest',
|
||||
// 'node:16.14.0-alpine',
|
||||
// 'alpine:latest',
|
||||
// 'nginx:stable-alpine',
|
||||
// 'node:lts',
|
||||
// 'php:apache',
|
||||
// 'rust:latest'
|
||||
// ];
|
||||
// for (const image of images) {
|
||||
// try {
|
||||
// await asyncExecShell(`DOCKER_HOST=${host} docker image inspect ${image}`);
|
||||
// } catch (error) {
|
||||
// await asyncExecShell(
|
||||
// `DOCKER_HOST=${host} docker pull ${image} && echo "FROM ${image}" | docker build --label coolify.image="true" -t "${image}" -`
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// } catch (error) {}
|
||||
try {
|
||||
await asyncExecShell(`DOCKER_HOST=${host} docker container prune -f`);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
if (!dev) {
|
||||
// Cleanup images that are not managed by coolify
|
||||
try {
|
||||
await asyncExecShell(
|
||||
`DOCKER_HOST=${host} docker image prune --filter 'label!=coolify.image=true' -a -f`
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
// Cleanup old images >3 days
|
||||
try {
|
||||
await asyncExecShell(`DOCKER_HOST=${host} docker image prune --filter "until=72h" -a -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 {
|
||||
// await asyncExecShell(
|
||||
// `DOCKER_HOST=${host} docker image prune --filter 'label!=coolify.image=true' -a -f`
|
||||
// );
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// }
|
||||
// // Cleanup old images >3 days
|
||||
// try {
|
||||
// await asyncExecShell(`DOCKER_HOST=${host} docker image prune --filter "until=72h" -a -f`);
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,104 +1,10 @@
|
||||
import { ErrorHandler } from '$lib/database';
|
||||
import { configureHAProxy } from '$lib/haproxy/configuration';
|
||||
|
||||
export default async function () {
|
||||
try {
|
||||
return await configureHAProxy();
|
||||
} catch (error) {
|
||||
console.log(error.response.body || error);
|
||||
ErrorHandler(error.response.body || error);
|
||||
}
|
||||
// const haproxy = await haproxyInstance();
|
||||
// await checkHAProxy(haproxy);
|
||||
// const transactionId = await getNextTransactionId();
|
||||
// let executeTransaction = {
|
||||
// applications: false,
|
||||
// services: false
|
||||
// }
|
||||
// try {
|
||||
// await checkProxyConfigurations();
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// }
|
||||
// try {
|
||||
// const applications = await db.prisma.application.findMany({
|
||||
// include: { destinationDocker: true }
|
||||
// });
|
||||
|
||||
// for (const application of applications) {
|
||||
// const {
|
||||
// fqdn,
|
||||
// id,
|
||||
// port,
|
||||
// destinationDocker: { engine }
|
||||
// } = application;
|
||||
// const containerRunning = await checkContainer(engine, id);
|
||||
// executeTransaction.applications = await configureHAProxy(
|
||||
// haproxy,
|
||||
// transactionId,
|
||||
// fqdn,
|
||||
// id,
|
||||
// port,
|
||||
// containerRunning,
|
||||
// engine
|
||||
// );
|
||||
// }
|
||||
|
||||
// const services = await db.prisma.service.findMany({
|
||||
// include: {
|
||||
// destinationDocker: true,
|
||||
// minio: true,
|
||||
// plausibleAnalytics: true,
|
||||
// vscodeserver: true,
|
||||
// wordpress: true
|
||||
// }
|
||||
// });
|
||||
|
||||
// for (const service of services) {
|
||||
// const {
|
||||
// fqdn,
|
||||
// id,
|
||||
// type,
|
||||
// destinationDocker: { engine }
|
||||
// } = service;
|
||||
// const found = db.supportedServiceTypesAndVersions.find((a) => a.name === type);
|
||||
// if (found) {
|
||||
// console.log(found);
|
||||
// const port = found.ports.main;
|
||||
// const publicPort = service[type]?.publicPort;
|
||||
// const containerRunning = await checkContainer(engine, id);
|
||||
// executeTransaction.services = await configureHAProxy(
|
||||
// haproxy,
|
||||
// transactionId,
|
||||
// fqdn,
|
||||
// id,
|
||||
// port,
|
||||
// containerRunning,
|
||||
// engine
|
||||
// );
|
||||
// if (publicPort) {
|
||||
// const containerFound = await checkContainer(
|
||||
// service.destinationDocker.engine,
|
||||
// `haproxy-for-${publicPort}`
|
||||
// );
|
||||
// if (!containerFound) {
|
||||
// await startHttpProxy(service.destinationDocker, id, publicPort, 9000);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (executeTransaction.applications || executeTransaction.services) {
|
||||
// await haproxy.put(`v2/services/haproxy/transactions/${transactionId}`);
|
||||
// }
|
||||
// // Check Coolify FQDN and configure proxy if needed
|
||||
// // const { fqdn } = await db.listSettings();
|
||||
// // if (fqdn) {
|
||||
// // const domain = getDomain(fqdn);
|
||||
// // await startCoolifyProxy('/var/run/docker.sock');
|
||||
// // await configureCoolifyProxyOn(fqdn);
|
||||
// // await setWwwRedirection(fqdn);
|
||||
// // const isHttps = fqdn.startsWith('https://');
|
||||
// // if (isHttps) await forceSSLOnApplication(domain);
|
||||
// // }
|
||||
// } catch (error) {
|
||||
// throw error;
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user