refactor
This commit is contained in:
parent
cb90f692f2
commit
823fe2deb2
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "coolify",
|
"name": "coolify",
|
||||||
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
|
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
|
||||||
"version": "2.0.23",
|
"version": "2.0.24",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "docker-compose -f docker-compose-dev.yaml up -d && NODE_ENV=development svelte-kit dev --host 0.0.0.0",
|
"dev": "docker-compose -f docker-compose-dev.yaml up -d && NODE_ENV=development svelte-kit dev --host 0.0.0.0",
|
||||||
|
@ -5,12 +5,12 @@ import crypto from 'crypto';
|
|||||||
|
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { checkContainer, checkHAProxy } from '.';
|
import { checkContainer, checkHAProxy } from '.';
|
||||||
import { getDomain } from '$lib/common';
|
import { asyncExecShell, getDomain, getEngine } from '$lib/common';
|
||||||
|
import { letsEncrypt } from '$lib/letsencrypt';
|
||||||
|
|
||||||
const url = dev ? 'http://localhost:5555' : 'http://coolify-haproxy:5555';
|
const url = dev ? 'http://localhost:5555' : 'http://coolify-haproxy:5555';
|
||||||
|
|
||||||
let template = `#coolhash={{hash}}
|
let template = `program api
|
||||||
program api
|
|
||||||
command /usr/bin/dataplaneapi -f /usr/local/etc/haproxy/dataplaneapi.hcl --userlist haproxy-dataplaneapi
|
command /usr/bin/dataplaneapi -f /usr/local/etc/haproxy/dataplaneapi.hcl --userlist haproxy-dataplaneapi
|
||||||
no option start-on-reload
|
no option start-on-reload
|
||||||
|
|
||||||
@ -44,6 +44,26 @@ frontend http
|
|||||||
dev ? 302 : 301
|
dev ? 302 : 301
|
||||||
} if { req.hdr(host) -i {{redirectTo}} }
|
} if { req.hdr(host) -i {{redirectTo}} }
|
||||||
{{/applications}}
|
{{/applications}}
|
||||||
|
{{#services}}
|
||||||
|
{{#isHttps}}
|
||||||
|
http-request redirect scheme https code ${
|
||||||
|
dev ? 302 : 301
|
||||||
|
} if { hdr(host) -i {{domain}} } !{ ssl_fc }
|
||||||
|
{{/isHttps}}
|
||||||
|
http-request redirect location {{{redirectValue}}} code ${
|
||||||
|
dev ? 302 : 301
|
||||||
|
} if { req.hdr(host) -i {{redirectTo}} }
|
||||||
|
{{/services}}
|
||||||
|
{{#coolify}}
|
||||||
|
{{#isHttps}}
|
||||||
|
http-request redirect scheme https code ${
|
||||||
|
dev ? 302 : 301
|
||||||
|
} if { hdr(host) -i {{domain}} } !{ ssl_fc }
|
||||||
|
{{/isHttps}}
|
||||||
|
http-request redirect location {{{redirectValue}}} code ${
|
||||||
|
dev ? 302 : 301
|
||||||
|
} if { req.hdr(host) -i {{redirectTo}} }
|
||||||
|
{{/coolify}}
|
||||||
use_backend backend-certbot if is_certbot
|
use_backend backend-certbot if is_certbot
|
||||||
use_backend %[req.hdr(host),lower]
|
use_backend %[req.hdr(host),lower]
|
||||||
|
|
||||||
@ -61,17 +81,28 @@ backend backend-certbot
|
|||||||
|
|
||||||
{{#applications}}
|
{{#applications}}
|
||||||
{{#isRunning}}
|
{{#isRunning}}
|
||||||
backend {{domain}}
|
|
||||||
option forwardfor
|
|
||||||
server {{id}} {{id}}:{{port}}
|
|
||||||
{{/isRunning}}
|
|
||||||
{{/applications}}
|
|
||||||
{{#services}}
|
|
||||||
|
|
||||||
backend {{domain}}
|
backend {{domain}}
|
||||||
option forwardfor
|
option forwardfor
|
||||||
server {{id}} {{id}}:{{port}}
|
server {{id}} {{id}}:{{port}} check
|
||||||
|
{{/isRunning}}
|
||||||
|
{{/applications}}
|
||||||
|
|
||||||
|
{{#services}}
|
||||||
|
{{#isRunning}}
|
||||||
|
|
||||||
|
backend {{domain}}
|
||||||
|
option forwardfor
|
||||||
|
server {{id}} {{id}}:{{port}} check
|
||||||
|
{{/isRunning}}
|
||||||
{{/services}}
|
{{/services}}
|
||||||
|
|
||||||
|
{{#coolify}}
|
||||||
|
backend {{domain}}
|
||||||
|
option forwardfor
|
||||||
|
option httpchk GET /undead.json
|
||||||
|
server {{id}} {{id}}:{{port}} check fall 10
|
||||||
|
{{/coolify}}
|
||||||
`;
|
`;
|
||||||
export async function haproxyInstance() {
|
export async function haproxyInstance() {
|
||||||
const { proxyPassword } = await db.listSettings();
|
const { proxyPassword } = await db.listSettings();
|
||||||
@ -85,26 +116,29 @@ export async function haproxyInstance() {
|
|||||||
export async function configureHAProxy() {
|
export async function configureHAProxy() {
|
||||||
const haproxy = await haproxyInstance();
|
const haproxy = await haproxyInstance();
|
||||||
await checkHAProxy(haproxy);
|
await checkHAProxy(haproxy);
|
||||||
|
const ssls = [];
|
||||||
const data = {
|
const data = {
|
||||||
applications: [],
|
applications: [],
|
||||||
services: []
|
services: [],
|
||||||
|
coolify: []
|
||||||
};
|
};
|
||||||
const applications = await db.prisma.application.findMany({
|
const applications = await db.prisma.application.findMany({
|
||||||
include: { destinationDocker: true }
|
include: { destinationDocker: true, settings: true }
|
||||||
});
|
});
|
||||||
for (const application of applications) {
|
for (const application of applications) {
|
||||||
const {
|
const {
|
||||||
fqdn,
|
fqdn,
|
||||||
id,
|
id,
|
||||||
port,
|
port,
|
||||||
destinationDocker: { engine }
|
destinationDocker: { engine, network },
|
||||||
|
settings: { previews }
|
||||||
} = application;
|
} = application;
|
||||||
const isRunning = await checkContainer(engine, id);
|
const isRunning = await checkContainer(engine, id);
|
||||||
if (isRunning) {
|
|
||||||
const domain = getDomain(fqdn);
|
const domain = getDomain(fqdn);
|
||||||
const isHttps = fqdn.startsWith('https://');
|
const isHttps = fqdn.startsWith('https://');
|
||||||
const isWWW = fqdn.includes('www.');
|
const isWWW = fqdn.includes('www.');
|
||||||
const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`;
|
const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`;
|
||||||
|
if (isRunning) {
|
||||||
data.applications.push({
|
data.applications.push({
|
||||||
id,
|
id,
|
||||||
port,
|
port,
|
||||||
@ -114,32 +148,90 @@ export async function configureHAProxy() {
|
|||||||
redirectValue,
|
redirectValue,
|
||||||
redirectTo: isWWW ? domain : 'www.' + domain
|
redirectTo: isWWW ? domain : 'www.' + domain
|
||||||
});
|
});
|
||||||
|
if (isHttps) ssls.push({ domain, id, isCoolify: false });
|
||||||
|
}
|
||||||
|
if (previews) {
|
||||||
|
const host = getEngine(engine);
|
||||||
|
const { stdout } = await asyncExecShell(
|
||||||
|
`DOCKER_HOST=${host} docker container ls --filter="status=running" --filter="network=${network}" --filter="name=${id}-" --format="{{json .Names}}"`
|
||||||
|
);
|
||||||
|
const containers = stdout
|
||||||
|
.trim()
|
||||||
|
.split('\n')
|
||||||
|
.filter((a) => a)
|
||||||
|
.map((c) => c.replace(/"/g, ''));
|
||||||
|
if (containers.length > 0) {
|
||||||
|
for (const container of containers) {
|
||||||
|
let previewDomain = `${container.split('-')[1]}.${domain}`;
|
||||||
|
data.applications.push({
|
||||||
|
id: container,
|
||||||
|
port,
|
||||||
|
domain: previewDomain,
|
||||||
|
isRunning,
|
||||||
|
isHttps,
|
||||||
|
redirectValue,
|
||||||
|
redirectTo: isWWW ? previewDomain : 'www.' + previewDomain
|
||||||
|
});
|
||||||
|
if (isHttps) ssls.push({ domain: previewDomain, id, isCoolify: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// const services = await db.prisma.service.findMany({
|
}
|
||||||
// include: {
|
}
|
||||||
// destinationDocker: true,
|
const services = await db.prisma.service.findMany({
|
||||||
// minio: true,
|
include: {
|
||||||
// plausibleAnalytics: true,
|
destinationDocker: true,
|
||||||
// vscodeserver: true,
|
minio: true,
|
||||||
// wordpress: true
|
plausibleAnalytics: true,
|
||||||
// }
|
vscodeserver: true,
|
||||||
// });
|
wordpress: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// for (const service of services) {
|
for (const service of services) {
|
||||||
// const {
|
const {
|
||||||
// fqdn,
|
fqdn,
|
||||||
// id,
|
id,
|
||||||
// type,
|
type,
|
||||||
// destinationDocker: { engine }
|
destinationDocker: { engine }
|
||||||
// } = service;
|
} = service;
|
||||||
// const found = db.supportedServiceTypesAndVersions.find((a) => a.name === type);
|
const found = db.supportedServiceTypesAndVersions.find((a) => a.name === type);
|
||||||
// if (found) {
|
if (found) {
|
||||||
// const port = found.ports.main;
|
const port = found.ports.main;
|
||||||
// const publicPort = service[type]?.publicPort;
|
const publicPort = service[type]?.publicPort;
|
||||||
// const isRunning = await checkContainer(engine, id);
|
const isRunning = await checkContainer(engine, id);
|
||||||
// }
|
const domain = getDomain(fqdn);
|
||||||
// }
|
const isHttps = fqdn.startsWith('https://');
|
||||||
|
const isWWW = fqdn.includes('www.');
|
||||||
|
const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`;
|
||||||
|
data.services.push({
|
||||||
|
id,
|
||||||
|
port,
|
||||||
|
publicPort,
|
||||||
|
domain,
|
||||||
|
isRunning,
|
||||||
|
isHttps,
|
||||||
|
redirectValue,
|
||||||
|
redirectTo: isWWW ? domain : 'www.' + domain
|
||||||
|
});
|
||||||
|
if (isHttps) ssls.push({ domain, id, isCoolify: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const { fqdn } = await db.prisma.setting.findFirst();
|
||||||
|
if (fqdn) {
|
||||||
|
const domain = getDomain(fqdn);
|
||||||
|
const isHttps = fqdn.startsWith('https://');
|
||||||
|
const isWWW = fqdn.includes('www.');
|
||||||
|
const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`;
|
||||||
|
data.coolify.push({
|
||||||
|
id: dev ? 'host.docker.internal' : 'coolify',
|
||||||
|
port: 3000,
|
||||||
|
domain,
|
||||||
|
isHttps,
|
||||||
|
redirectValue,
|
||||||
|
redirectTo: isWWW ? domain : 'www.' + domain
|
||||||
|
});
|
||||||
|
if (!dev && isHttps) ssls.push({ domain, id: 'coolify', isCoolify: true });
|
||||||
|
}
|
||||||
const output = mustache.render(template, data);
|
const output = mustache.render(template, data);
|
||||||
const newHash = crypto.createHash('md5').update(output).digest('hex');
|
const newHash = crypto.createHash('md5').update(output).digest('hex');
|
||||||
const { proxyHash, id } = await db.listSettings();
|
const { proxyHash, id } = await db.listSettings();
|
||||||
@ -156,6 +248,15 @@ export async function configureHAProxy() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('HAProxy configuration is up to date');
|
// console.log('HAProxy configuration is up to date');
|
||||||
|
}
|
||||||
|
if (ssls.length > 0) {
|
||||||
|
for (const ssl of ssls) {
|
||||||
|
if (!dev) {
|
||||||
|
await letsEncrypt(ssl.domain, ssl.id, ssl.isCoolify);
|
||||||
|
} else {
|
||||||
|
// console.log('Generate ssl for', ssl.domain);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@ export async function letsEncrypt(domain, id = null, isCoolify = false) {
|
|||||||
const nakedDomain = domain.replace('www.', '');
|
const nakedDomain = domain.replace('www.', '');
|
||||||
const wwwDomain = `www.${nakedDomain}`;
|
const wwwDomain = `www.${nakedDomain}`;
|
||||||
const randomCuid = cuid();
|
const randomCuid = cuid();
|
||||||
const randomPort = await getPort({ port: portNumbers(minPort, maxPort) });
|
const randomPort = 9000;
|
||||||
|
|
||||||
let host;
|
let host;
|
||||||
let dualCerts = false;
|
let dualCerts = false;
|
||||||
|
@ -256,26 +256,5 @@ export default async function (job) {
|
|||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
saveBuildLog({ line: 'Proxy will be configured shortly.', buildId, applicationId });
|
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) {
|
for (const destinationDocker of destinationDockers) {
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
// Tagging images with labels
|
// Tagging images with labels
|
||||||
try {
|
// try {
|
||||||
const images = [
|
// const images = [
|
||||||
`coollabsio/${defaultProxyImageTcp}`,
|
// `coollabsio/${defaultProxyImageTcp}`,
|
||||||
`coollabsio/${defaultProxyImageHttp}`,
|
// `coollabsio/${defaultProxyImageHttp}`,
|
||||||
'certbot/certbot:latest',
|
// 'certbot/certbot:latest',
|
||||||
'node:16.14.0-alpine',
|
// 'node:16.14.0-alpine',
|
||||||
'alpine:latest',
|
// 'alpine:latest',
|
||||||
'nginx:stable-alpine',
|
// 'nginx:stable-alpine',
|
||||||
'node:lts',
|
// 'node:lts',
|
||||||
'php:apache',
|
// 'php:apache',
|
||||||
'rust:latest'
|
// 'rust:latest'
|
||||||
];
|
// ];
|
||||||
for (const image of images) {
|
// for (const image of images) {
|
||||||
try {
|
// try {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker image inspect ${image}`);
|
// await asyncExecShell(`DOCKER_HOST=${host} docker image inspect ${image}`);
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
await asyncExecShell(
|
// await asyncExecShell(
|
||||||
`DOCKER_HOST=${host} docker pull ${image} && echo "FROM ${image}" | docker build --label coolify.image="true" -t "${image}" -`
|
// `DOCKER_HOST=${host} docker pull ${image} && echo "FROM ${image}" | docker build --label coolify.image="true" -t "${image}" -`
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} catch (error) {}
|
// } catch (error) {}
|
||||||
try {
|
try {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker container prune -f`);
|
await asyncExecShell(`DOCKER_HOST=${host} docker container prune -f`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
if (!dev) {
|
|
||||||
// Cleanup images that are not managed by coolify
|
|
||||||
try {
|
try {
|
||||||
await asyncExecShell(
|
await asyncExecShell(`DOCKER_HOST=${host} docker image prune -f`);
|
||||||
`DOCKER_HOST=${host} docker image prune --filter 'label!=coolify.image=true' -a -f`
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
// Cleanup old images >3 days
|
// if (!dev) {
|
||||||
try {
|
// // Cleanup images that are not managed by coolify
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker image prune --filter "until=72h" -a -f`);
|
// try {
|
||||||
} catch (error) {
|
// await asyncExecShell(
|
||||||
console.log(error);
|
// `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';
|
import { configureHAProxy } from '$lib/haproxy/configuration';
|
||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
try {
|
try {
|
||||||
return await configureHAProxy();
|
return await configureHAProxy();
|
||||||
} catch (error) {
|
} 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;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -44,33 +44,19 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mx-auto max-w-6xl rounded-xl px-6 pt-4">
|
<div class="mx-auto max-w-6xl rounded-xl px-6 pt-4">
|
||||||
<table class="mx-auto">
|
<table class="mx-auto border-separate text-left">
|
||||||
<thead class=" rounded-xl border-b border-coolgray-500">
|
<thead>
|
||||||
<tr>
|
<tr class="h-12">
|
||||||
<th
|
<th scope="col">Name</th>
|
||||||
scope="col"
|
<th scope="col">Value</th>
|
||||||
class="px-6 py-3 text-left text-xs font-bold uppercase tracking-wider text-white">Name</th
|
<th scope="col" class="w-64 text-center">Need during buildtime?</th>
|
||||||
>
|
<th scope="col" class="w-96 text-center">Action</th>
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
class="px-6 py-3 text-left text-xs font-bold uppercase tracking-wider text-white"
|
|
||||||
>Value</th
|
|
||||||
>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
class="px-6 py-3 text-left text-xs font-bold uppercase tracking-wider text-white"
|
|
||||||
>Need during buildtime?</th
|
|
||||||
>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
class="px-6 py-3 text-left text-xs font-bold uppercase tracking-wider text-white"
|
|
||||||
/>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="">
|
<tbody>
|
||||||
{#each applicationSecrets as secret}
|
{#each applicationSecrets as secret}
|
||||||
{#key secret.id}
|
{#key secret.id}
|
||||||
<tr class="h-20 transition duration-100 hover:bg-coolgray-400">
|
<tr>
|
||||||
<Secret
|
<Secret
|
||||||
PRMRSecret={PRMRSecrets.find((s) => s.name === secret.name)}
|
PRMRSecret={PRMRSecrets.find((s) => s.name === secret.name)}
|
||||||
isPRMRSecret
|
isPRMRSecret
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { getDomain, getUserDetails } from '$lib/common';
|
import { asyncExecShell, getEngine, getUserDetails, removeDestinationDocker } from '$lib/common';
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { dockerInstance } from '$lib/docker';
|
import { checkContainer } from '$lib/haproxy';
|
||||||
import { removeProxyConfiguration } from '$lib/haproxy';
|
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@ -17,10 +16,12 @@ export const post: RequestHandler = async (event) => {
|
|||||||
teamId
|
teamId
|
||||||
});
|
});
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
const docker = dockerInstance({ destinationDocker });
|
const { engine } = destinationDocker;
|
||||||
await docker.engine.getContainer(id).stop();
|
const found = await checkContainer(engine, id);
|
||||||
|
if (found) {
|
||||||
|
await removeDestinationDocker({ id, engine });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// await removeProxyConfiguration(fqdn);
|
|
||||||
return {
|
return {
|
||||||
status: 200
|
status: 200
|
||||||
};
|
};
|
||||||
|
@ -1,30 +1,19 @@
|
|||||||
import { getDomain, getUserDetails } from '$lib/common';
|
import { getUserDetails } from '$lib/common';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import {
|
import { startCoolifyProxy, stopCoolifyProxy } from '$lib/haproxy';
|
||||||
configureCoolifyProxyOn,
|
|
||||||
forceSSLOnApplication,
|
|
||||||
setWwwRedirection,
|
|
||||||
startCoolifyProxy,
|
|
||||||
stopCoolifyProxy
|
|
||||||
} from '$lib/haproxy';
|
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
const { teamId, status, body } = await getUserDetails(event);
|
const { teamId, status, body } = await getUserDetails(event);
|
||||||
if (status === 401) return { status, body };
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
const { engine, fqdn } = await event.request.json();
|
const { engine } = await event.request.json();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
await stopCoolifyProxy(engine);
|
await stopCoolifyProxy(engine);
|
||||||
await startCoolifyProxy(engine);
|
await startCoolifyProxy(engine);
|
||||||
await db.setDestinationSettings({ engine, isCoolifyProxyUsed: true });
|
await db.setDestinationSettings({ engine, isCoolifyProxyUsed: true });
|
||||||
await configureCoolifyProxyOn(fqdn);
|
|
||||||
await setWwwRedirection(fqdn);
|
|
||||||
const isHttps = fqdn.startsWith('https://');
|
|
||||||
if (isHttps) await forceSSLOnApplication(domain);
|
|
||||||
return {
|
return {
|
||||||
status: 200
|
status: 200
|
||||||
};
|
};
|
||||||
|
@ -3,15 +3,7 @@ import * as db from '$lib/database';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { letsEncrypt } from '$lib/letsencrypt';
|
import { startHttpProxy } from '$lib/haproxy';
|
||||||
import {
|
|
||||||
checkHAProxy,
|
|
||||||
checkProxyConfigurations,
|
|
||||||
configureSimpleServiceProxyOn,
|
|
||||||
reloadHaproxy,
|
|
||||||
setWwwRedirection,
|
|
||||||
startHttpProxy
|
|
||||||
} from '$lib/haproxy';
|
|
||||||
import getPort, { portNumbers } from 'get-port';
|
import getPort, { portNumbers } from 'get-port';
|
||||||
import { getDomain } from '$lib/components/common';
|
import { getDomain } from '$lib/components/common';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
@ -24,7 +16,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const { id } = event.params;
|
const { id } = event.params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// await checkHAProxy();
|
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const {
|
const {
|
||||||
type,
|
type,
|
||||||
@ -38,9 +29,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const data = await db.prisma.setting.findFirst();
|
const data = await db.prisma.setting.findFirst();
|
||||||
const { minPort, maxPort } = data;
|
const { minPort, maxPort } = data;
|
||||||
|
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
const isHttps = fqdn.startsWith('https://');
|
|
||||||
|
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
|
||||||
@ -96,16 +84,8 @@ export const post: RequestHandler = async (event) => {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
|
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
|
||||||
// await checkProxyConfigurations();
|
|
||||||
// await configureSimpleServiceProxyOn({ id, domain, port: consolePort });
|
|
||||||
await db.updateMinioService({ id, publicPort });
|
await db.updateMinioService({ id, publicPort });
|
||||||
await startHttpProxy(destinationDocker, id, publicPort, apiPort);
|
await startHttpProxy(destinationDocker, id, publicPort, apiPort);
|
||||||
|
|
||||||
// if (isHttps) {
|
|
||||||
// await letsEncrypt({ domain, id });
|
|
||||||
// }
|
|
||||||
// await setWwwRedirection(fqdn);
|
|
||||||
// await reloadHaproxy(destinationDocker.engine);
|
|
||||||
return {
|
return {
|
||||||
status: 200
|
status: 200
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { getEngine, getUserDetails, removeDestinationDocker } from '$lib/common';
|
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { dockerInstance } from '$lib/docker';
|
import { checkContainer, stopTcpHttpProxy } from '$lib/haproxy';
|
||||||
import { checkContainer, configureSimpleServiceProxyOff, stopTcpHttpProxy } from '$lib/haproxy';
|
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@ -21,7 +19,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
minio: { publicPort }
|
minio: { publicPort }
|
||||||
} = service;
|
} = service;
|
||||||
await db.updateMinioService({ id, publicPort: null });
|
await db.updateMinioService({ id, publicPort: null });
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
const engine = destinationDocker.engine;
|
const engine = destinationDocker.engine;
|
||||||
|
|
||||||
@ -35,7 +32,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await stopTcpHttpProxy(destinationDocker, publicPort);
|
await stopTcpHttpProxy(destinationDocker, publicPort);
|
||||||
// await configureSimpleServiceProxyOff(fqdn);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,6 @@ import * as db from '$lib/database';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { letsEncrypt } from '$lib/letsencrypt';
|
|
||||||
import {
|
|
||||||
checkHAProxy,
|
|
||||||
checkProxyConfigurations,
|
|
||||||
configureSimpleServiceProxyOn,
|
|
||||||
reloadHaproxy,
|
|
||||||
setWwwRedirection
|
|
||||||
} from '$lib/haproxy';
|
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { makeLabelForServices } from '$lib/buildPacks/common';
|
import { makeLabelForServices } from '$lib/buildPacks/common';
|
||||||
|
|
||||||
@ -22,13 +13,8 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const { id } = event.params;
|
const { id } = event.params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await checkHAProxy();
|
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const { type, version, fqdn, destinationDockerId, destinationDocker } = service;
|
const { type, version, destinationDockerId, destinationDocker } = service;
|
||||||
|
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
const isHttps = fqdn.startsWith('https://');
|
|
||||||
|
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
|
||||||
@ -56,14 +42,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
|
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
|
||||||
// await checkProxyConfigurations();
|
|
||||||
// await configureSimpleServiceProxyOn({ id, domain, port: 8080 });
|
|
||||||
|
|
||||||
// if (isHttps) {
|
|
||||||
// await letsEncrypt({ domain, id });
|
|
||||||
// }
|
|
||||||
// await setWwwRedirection(fqdn);
|
|
||||||
// await reloadHaproxy(destinationDocker.engine);
|
|
||||||
return {
|
return {
|
||||||
status: 200
|
status: 200
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { dockerInstance } from '$lib/docker';
|
import { checkContainer } from '$lib/haproxy';
|
||||||
import { checkContainer, configureSimpleServiceProxyOff } from '$lib/haproxy';
|
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@ -15,7 +13,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
try {
|
try {
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const { destinationDockerId, destinationDocker, fqdn } = service;
|
const { destinationDockerId, destinationDocker, fqdn } = service;
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
const engine = destinationDocker.engine;
|
const engine = destinationDocker.engine;
|
||||||
|
|
||||||
@ -27,11 +24,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
await configureSimpleServiceProxyOff(fqdn);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -3,15 +3,6 @@ import * as db from '$lib/database';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { letsEncrypt } from '$lib/letsencrypt';
|
|
||||||
import {
|
|
||||||
checkHAProxy,
|
|
||||||
checkProxyConfigurations,
|
|
||||||
configureSimpleServiceProxyOn,
|
|
||||||
reloadHaproxy,
|
|
||||||
setWwwRedirection
|
|
||||||
} from '$lib/haproxy';
|
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { makeLabelForServices } from '$lib/buildPacks/common';
|
import { makeLabelForServices } from '$lib/buildPacks/common';
|
||||||
|
|
||||||
@ -22,7 +13,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const { id } = event.params;
|
const { id } = event.params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await checkHAProxy();
|
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const {
|
const {
|
||||||
type,
|
type,
|
||||||
@ -42,9 +32,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
}
|
}
|
||||||
} = service;
|
} = service;
|
||||||
|
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
const isHttps = fqdn.startsWith('https://');
|
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
plausibleAnalytics: {
|
plausibleAnalytics: {
|
||||||
image: `plausible/analytics:${version}`,
|
image: `plausible/analytics:${version}`,
|
||||||
@ -83,7 +70,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
};
|
};
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
const engine = destinationDocker.engine;
|
|
||||||
|
|
||||||
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
||||||
|
|
||||||
@ -187,14 +173,7 @@ COPY ./init-db.sh /docker-entrypoint-initdb.d/init-db.sh`;
|
|||||||
await asyncExecShell(
|
await asyncExecShell(
|
||||||
`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up --build -d`
|
`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up --build -d`
|
||||||
);
|
);
|
||||||
// await checkProxyConfigurations();
|
|
||||||
// await configureSimpleServiceProxyOn({ id, domain, port: 8000 });
|
|
||||||
|
|
||||||
// if (isHttps) {
|
|
||||||
// await letsEncrypt({ domain, id });
|
|
||||||
// }
|
|
||||||
// await setWwwRedirection(fqdn);
|
|
||||||
// await reloadHaproxy(destinationDocker.engine);
|
|
||||||
return {
|
return {
|
||||||
status: 200
|
status: 200
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { dockerInstance } from '$lib/docker';
|
import { checkContainer } from '$lib/haproxy';
|
||||||
import { checkContainer, configureSimpleServiceProxyOff } from '$lib/haproxy';
|
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@ -15,7 +13,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
try {
|
try {
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const { destinationDockerId, destinationDocker, fqdn } = service;
|
const { destinationDockerId, destinationDocker, fqdn } = service;
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
|
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
const engine = destinationDocker.engine;
|
const engine = destinationDocker.engine;
|
||||||
@ -36,12 +33,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
await configureSimpleServiceProxyOff(fqdn);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -3,15 +3,6 @@ import * as db from '$lib/database';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { letsEncrypt } from '$lib/letsencrypt';
|
|
||||||
import {
|
|
||||||
checkHAProxy,
|
|
||||||
checkProxyConfigurations,
|
|
||||||
configureSimpleServiceProxyOn,
|
|
||||||
reloadHaproxy,
|
|
||||||
setWwwRedirection
|
|
||||||
} from '$lib/haproxy';
|
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import { getServiceImage, ErrorHandler } from '$lib/database';
|
import { getServiceImage, ErrorHandler } from '$lib/database';
|
||||||
import { makeLabelForServices } from '$lib/buildPacks/common';
|
import { makeLabelForServices } from '$lib/buildPacks/common';
|
||||||
|
|
||||||
@ -22,12 +13,8 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const { id } = event.params;
|
const { id } = event.params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await checkHAProxy();
|
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const { type, version, fqdn, destinationDockerId, destinationDocker } = service;
|
const { type, version, destinationDockerId, destinationDocker } = service;
|
||||||
|
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
const isHttps = fqdn.startsWith('https://');
|
|
||||||
|
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
@ -74,14 +61,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
|
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
|
||||||
// await checkProxyConfigurations();
|
|
||||||
// await configureSimpleServiceProxyOn({ id, domain, port: 80 });
|
|
||||||
|
|
||||||
// if (isHttps) {
|
|
||||||
// await letsEncrypt({ domain, id });
|
|
||||||
// }
|
|
||||||
// await setWwwRedirection(fqdn);
|
|
||||||
// await reloadHaproxy(destinationDocker.engine);
|
|
||||||
return {
|
return {
|
||||||
status: 200
|
status: 200
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { dockerInstance } from '$lib/docker';
|
import { checkContainer } from '$lib/haproxy';
|
||||||
import { checkContainer, configureSimpleServiceProxyOff } from '$lib/haproxy';
|
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@ -15,7 +13,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
try {
|
try {
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const { destinationDockerId, destinationDocker, fqdn } = service;
|
const { destinationDockerId, destinationDocker, fqdn } = service;
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
const engine = destinationDocker.engine;
|
const engine = destinationDocker.engine;
|
||||||
|
|
||||||
@ -27,13 +24,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
await configureSimpleServiceProxyOff(fqdn);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: 200
|
status: 200
|
||||||
};
|
};
|
||||||
|
@ -3,15 +3,6 @@ import * as db from '$lib/database';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { letsEncrypt } from '$lib/letsencrypt';
|
|
||||||
import {
|
|
||||||
checkHAProxy,
|
|
||||||
checkProxyConfigurations,
|
|
||||||
configureSimpleServiceProxyOn,
|
|
||||||
reloadHaproxy,
|
|
||||||
setWwwRedirection
|
|
||||||
} from '$lib/haproxy';
|
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { makeLabelForServices } from '$lib/buildPacks/common';
|
import { makeLabelForServices } from '$lib/buildPacks/common';
|
||||||
|
|
||||||
@ -22,20 +13,15 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const { id } = event.params;
|
const { id } = event.params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await checkHAProxy();
|
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const {
|
const {
|
||||||
type,
|
type,
|
||||||
version,
|
version,
|
||||||
fqdn,
|
|
||||||
destinationDockerId,
|
destinationDockerId,
|
||||||
destinationDocker,
|
destinationDocker,
|
||||||
vscodeserver: { password }
|
vscodeserver: { password }
|
||||||
} = service;
|
} = service;
|
||||||
|
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
const isHttps = fqdn.startsWith('https://');
|
|
||||||
|
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
|
||||||
@ -84,14 +70,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
|
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
|
||||||
// await checkProxyConfigurations();
|
|
||||||
// await configureSimpleServiceProxyOn({ id, domain, port: 8080 });
|
|
||||||
|
|
||||||
// if (isHttps) {
|
|
||||||
// await letsEncrypt({ domain, id });
|
|
||||||
// }
|
|
||||||
// await setWwwRedirection(fqdn);
|
|
||||||
// await reloadHaproxy(destinationDocker.engine);
|
|
||||||
return {
|
return {
|
||||||
status: 200
|
status: 200
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { dockerInstance } from '$lib/docker';
|
import { checkContainer } from '$lib/haproxy';
|
||||||
import { checkContainer, configureSimpleServiceProxyOff } from '$lib/haproxy';
|
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@ -15,7 +13,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
try {
|
try {
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const { destinationDockerId, destinationDocker, fqdn } = service;
|
const { destinationDockerId, destinationDocker, fqdn } = service;
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
const engine = destinationDocker.engine;
|
const engine = destinationDocker.engine;
|
||||||
|
|
||||||
@ -27,11 +24,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
await configureSimpleServiceProxyOff(fqdn);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
status: 200
|
status: 200
|
||||||
|
@ -3,15 +3,6 @@ import * as db from '$lib/database';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { letsEncrypt } from '$lib/letsencrypt';
|
|
||||||
import {
|
|
||||||
checkHAProxy,
|
|
||||||
checkProxyConfigurations,
|
|
||||||
configureSimpleServiceProxyOn,
|
|
||||||
reloadHaproxy,
|
|
||||||
setWwwRedirection
|
|
||||||
} from '$lib/haproxy';
|
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { makeLabelForServices } from '$lib/buildPacks/common';
|
import { makeLabelForServices } from '$lib/buildPacks/common';
|
||||||
|
|
||||||
@ -22,7 +13,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const { id } = event.params;
|
const { id } = event.params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await checkHAProxy();
|
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const {
|
const {
|
||||||
type,
|
type,
|
||||||
@ -40,9 +30,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
}
|
}
|
||||||
} = service;
|
} = service;
|
||||||
|
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
const isHttps = fqdn.startsWith('https://');
|
|
||||||
|
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const host = getEngine(destinationDocker.engine);
|
const host = getEngine(destinationDocker.engine);
|
||||||
|
|
||||||
@ -121,14 +108,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
|
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
|
||||||
// await checkProxyConfigurations();
|
|
||||||
// await configureSimpleServiceProxyOn({ id, domain, port: 80 });
|
|
||||||
|
|
||||||
// if (isHttps) {
|
|
||||||
// await letsEncrypt({ domain, id });
|
|
||||||
// }
|
|
||||||
// await setWwwRedirection(fqdn);
|
|
||||||
// await reloadHaproxy(destinationDocker.engine);
|
|
||||||
return {
|
return {
|
||||||
status: 200
|
status: 200
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
import { getUserDetails, removeDestinationDocker } from '$lib/common';
|
||||||
import { getDomain } from '$lib/components/common';
|
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
import { dockerInstance } from '$lib/docker';
|
import { checkContainer } from '$lib/haproxy';
|
||||||
import { checkContainer, configureSimpleServiceProxyOff } from '$lib/haproxy';
|
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
@ -15,7 +13,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
try {
|
try {
|
||||||
const service = await db.getService({ id, teamId });
|
const service = await db.getService({ id, teamId });
|
||||||
const { destinationDockerId, destinationDocker, fqdn } = service;
|
const { destinationDockerId, destinationDocker, fqdn } = service;
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
const engine = destinationDocker.engine;
|
const engine = destinationDocker.engine;
|
||||||
try {
|
try {
|
||||||
@ -30,11 +27,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
await configureSimpleServiceProxyOff(fqdn);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1,18 +1,6 @@
|
|||||||
import { dev } from '$app/env';
|
import { getUserDetails } from '$lib/common';
|
||||||
import { getDomain, getUserDetails } from '$lib/common';
|
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { listSettings, ErrorHandler } from '$lib/database';
|
import { listSettings, ErrorHandler } from '$lib/database';
|
||||||
import {
|
|
||||||
checkProxyConfigurations,
|
|
||||||
configureCoolifyProxyOff,
|
|
||||||
configureCoolifyProxyOn,
|
|
||||||
forceSSLOnApplication,
|
|
||||||
reloadHaproxy,
|
|
||||||
removeWwwRedirection,
|
|
||||||
setWwwRedirection,
|
|
||||||
startCoolifyProxy
|
|
||||||
} from '$lib/haproxy';
|
|
||||||
import { letsEncrypt } from '$lib/letsencrypt';
|
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
import { promises as dns } from 'dns';
|
import { promises as dns } from 'dns';
|
||||||
|
|
||||||
@ -52,10 +40,7 @@ export const del: RequestHandler = async (event) => {
|
|||||||
// Do not care.
|
// Do not care.
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
await db.prisma.setting.update({ where: { fqdn }, data: { fqdn: null } });
|
await db.prisma.setting.update({ where: { fqdn }, data: { fqdn: null } });
|
||||||
await configureCoolifyProxyOff(fqdn);
|
|
||||||
await removeWwwRedirection(domain);
|
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
body: {
|
body: {
|
||||||
@ -80,50 +65,19 @@ export const post: RequestHandler = async (event) => {
|
|||||||
|
|
||||||
const { fqdn, isRegistrationEnabled, dualCerts, minPort, maxPort } = await event.request.json();
|
const { fqdn, isRegistrationEnabled, dualCerts, minPort, maxPort } = await event.request.json();
|
||||||
try {
|
try {
|
||||||
await checkProxyConfigurations();
|
const { id } = await db.listSettings();
|
||||||
const {
|
if (isRegistrationEnabled) {
|
||||||
id,
|
|
||||||
fqdn: oldFqdn,
|
|
||||||
isRegistrationEnabled: oldIsRegistrationEnabled,
|
|
||||||
dualCerts: oldDualCerts
|
|
||||||
} = await db.listSettings();
|
|
||||||
if (oldIsRegistrationEnabled !== isRegistrationEnabled) {
|
|
||||||
await db.prisma.setting.update({ where: { id }, data: { isRegistrationEnabled } });
|
await db.prisma.setting.update({ where: { id }, data: { isRegistrationEnabled } });
|
||||||
}
|
}
|
||||||
if (oldDualCerts !== dualCerts) {
|
|
||||||
await db.prisma.setting.update({ where: { id }, data: { dualCerts } });
|
|
||||||
}
|
|
||||||
if (oldFqdn && oldFqdn !== fqdn) {
|
|
||||||
if (oldFqdn) {
|
|
||||||
const oldDomain = getDomain(oldFqdn);
|
|
||||||
await configureCoolifyProxyOff(oldFqdn);
|
|
||||||
await removeWwwRedirection(oldDomain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fqdn) {
|
if (fqdn) {
|
||||||
await startCoolifyProxy('/var/run/docker.sock');
|
|
||||||
const domain = getDomain(fqdn);
|
|
||||||
const isHttps = fqdn.startsWith('https://');
|
|
||||||
if (domain) {
|
|
||||||
await configureCoolifyProxyOn(fqdn);
|
|
||||||
await setWwwRedirection(fqdn);
|
|
||||||
if (isHttps) {
|
|
||||||
await letsEncrypt({ domain, isCoolify: true });
|
|
||||||
await forceSSLOnApplication(domain);
|
|
||||||
await reloadHaproxy('/var/run/docker.sock');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.prisma.setting.update({ where: { id }, data: { fqdn } });
|
await db.prisma.setting.update({ where: { id }, data: { fqdn } });
|
||||||
await db.prisma.destinationDocker.updateMany({
|
}
|
||||||
where: { engine: '/var/run/docker.sock' },
|
if (dualCerts) {
|
||||||
data: { isCoolifyProxyUsed: true }
|
await db.prisma.setting.update({ where: { id }, data: { dualCerts } });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (minPort && maxPort) {
|
if (minPort && maxPort) {
|
||||||
await db.prisma.setting.update({ where: { id }, data: { minPort, maxPort } });
|
await db.prisma.setting.update({ where: { id }, data: { minPort, maxPort } });
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: 201
|
status: 201
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user