WIP
This commit is contained in:
@@ -2,16 +2,21 @@ import * as db from '$lib/database';
|
||||
import { getDomain } from '$lib/common';
|
||||
import {
|
||||
checkContainer,
|
||||
checkHAProxy,
|
||||
checkProxyConfigurations,
|
||||
configureCoolifyProxyOn,
|
||||
configureHAProxy,
|
||||
forceSSLOnApplication,
|
||||
haproxyInstance,
|
||||
setWwwRedirection,
|
||||
startCoolifyProxy,
|
||||
startHttpProxy
|
||||
} from '$lib/haproxy';
|
||||
|
||||
export default async function () {
|
||||
const haproxy = await haproxyInstance();
|
||||
await checkHAProxy(haproxy);
|
||||
let transactionId;
|
||||
try {
|
||||
await checkProxyConfigurations();
|
||||
} catch (error) {
|
||||
@@ -30,7 +35,15 @@ export default async function () {
|
||||
destinationDocker: { engine }
|
||||
} = application;
|
||||
const containerRunning = await checkContainer(engine, id);
|
||||
await configureHAProxy(fqdn, id, port, containerRunning, engine);
|
||||
transactionId = await configureHAProxy(
|
||||
haproxy,
|
||||
transactionId,
|
||||
fqdn,
|
||||
id,
|
||||
port,
|
||||
containerRunning,
|
||||
engine
|
||||
);
|
||||
}
|
||||
|
||||
const services = await db.prisma.service.findMany({
|
||||
@@ -50,12 +63,23 @@ export default async function () {
|
||||
type,
|
||||
destinationDocker: { engine }
|
||||
} = service;
|
||||
console.log({ fqdn, id, type, engine });
|
||||
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);
|
||||
await configureHAProxy(fqdn, id, port, containerRunning, engine);
|
||||
console.log(containerRunning);
|
||||
transactionId = await configureHAProxy(
|
||||
haproxy,
|
||||
transactionId,
|
||||
fqdn,
|
||||
id,
|
||||
port,
|
||||
containerRunning,
|
||||
engine
|
||||
);
|
||||
if (publicPort) {
|
||||
const containerFound = await checkContainer(
|
||||
service.destinationDocker.engine,
|
||||
@@ -67,16 +91,18 @@ export default async function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(transactionId);
|
||||
if (transactionId) 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);
|
||||
}
|
||||
// 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