fix: Minio urls + domain checks

This commit is contained in:
Andras Bacsai
2022-05-19 13:45:17 +02:00
parent b01f5f47b3
commit 6fb6a514ac
13 changed files with 270 additions and 96 deletions

View File

@@ -51,10 +51,12 @@ export async function isSecretExists({
export async function isDomainConfigured({
id,
fqdn
fqdn,
checkOwn = false
}: {
id: string;
fqdn: string;
checkOwn?: boolean;
}): Promise<boolean> {
const domain = getDomain(fqdn);
const nakedDomain = domain.replace('www.', '');
@@ -72,12 +74,15 @@ export async function isDomainConfigured({
where: {
OR: [
{ fqdn: { endsWith: `//${nakedDomain}` } },
{ fqdn: { endsWith: `//www.${nakedDomain}` } }
{ fqdn: { endsWith: `//www.${nakedDomain}` } },
{ minio: { apiFqdn: { endsWith: `//${nakedDomain}` } } },
{ minio: { apiFqdn: { endsWith: `//www.${nakedDomain}` } } }
],
id: { not: id }
id: { not: checkOwn ? undefined : id }
},
select: { fqdn: true }
});
const coolifyFqdn = await prisma.setting.findFirst({
where: {
OR: [

View File

@@ -305,12 +305,12 @@ export async function getFreePort() {
select: { mysqlPublicPort: true }
})
).map((a) => a.mysqlPublicPort);
const minioUSed = await (
const minioUsed = await (
await prisma.minio.findMany({
where: { publicPort: { not: null } },
select: { publicPort: true }
})
).map((a) => a.publicPort);
const usedPorts = [...dbUsed, ...wpFtpUsed, ...wpUsed, ...minioUSed];
const usedPorts = [...dbUsed, ...wpFtpUsed, ...wpUsed, ...minioUsed];
return await getPort({ port: portNumbers(minPort, maxPort), exclude: usedPorts });
}

View File

@@ -360,7 +360,24 @@ export async function updateService({
}): Promise<Service> {
return await prisma.service.update({ where: { id }, data: { fqdn, name, exposePort } });
}
export async function updateMinioService({
id,
fqdn,
apiFqdn,
exposePort,
name
}: {
id: string;
fqdn: string;
apiFqdn: string;
exposePort?: number;
name: string;
}): Promise<Service> {
return await prisma.service.update({
where: { id },
data: { fqdn, name, exposePort, minio: { update: { apiFqdn } } }
});
}
export async function updateFiderService({
id,
fqdn,
@@ -459,7 +476,7 @@ export async function updateWordpress({
});
}
export async function updateMinioService({
export async function updateMinioServicePort({
id,
publicPort
}: {