fix: Builder debug logging is better now
fix: www and non-www domain checker
This commit is contained in:
@@ -21,16 +21,35 @@ export async function isSecretExists({ id, name }) {
|
|||||||
|
|
||||||
export async function isDomainConfigured({ id, fqdn }) {
|
export async function isDomainConfigured({ id, fqdn }) {
|
||||||
const domain = getDomain(fqdn);
|
const domain = getDomain(fqdn);
|
||||||
|
const nakedDomain = domain.replace('www.', '');
|
||||||
const foundApp = await prisma.application.findFirst({
|
const foundApp = await prisma.application.findFirst({
|
||||||
where: { fqdn: { endsWith: `//${domain}` }, id: { not: id } },
|
where: {
|
||||||
|
OR: [
|
||||||
|
{ fqdn: { endsWith: `//${nakedDomain}` } },
|
||||||
|
{ fqdn: { endsWith: `//www.${nakedDomain}` } }
|
||||||
|
],
|
||||||
|
id: { not: id }
|
||||||
|
},
|
||||||
select: { fqdn: true }
|
select: { fqdn: true }
|
||||||
});
|
});
|
||||||
const foundService = await prisma.service.findFirst({
|
const foundService = await prisma.service.findFirst({
|
||||||
where: { fqdn: { endsWith: `//${domain}` }, id: { not: id } },
|
where: {
|
||||||
|
OR: [
|
||||||
|
{ fqdn: { endsWith: `//${nakedDomain}` } },
|
||||||
|
{ fqdn: { endsWith: `//www.${nakedDomain}` } }
|
||||||
|
],
|
||||||
|
id: { not: id }
|
||||||
|
},
|
||||||
select: { fqdn: true }
|
select: { fqdn: true }
|
||||||
});
|
});
|
||||||
const coolifyFqdn = await prisma.setting.findFirst({
|
const coolifyFqdn = await prisma.setting.findFirst({
|
||||||
where: { fqdn: { endsWith: `//${domain}` }, id: { not: id } },
|
where: {
|
||||||
|
OR: [
|
||||||
|
{ fqdn: { endsWith: `//${nakedDomain}` } },
|
||||||
|
{ fqdn: { endsWith: `//www.${nakedDomain}` } }
|
||||||
|
],
|
||||||
|
id: { not: id }
|
||||||
|
},
|
||||||
select: { fqdn: true }
|
select: { fqdn: true }
|
||||||
});
|
});
|
||||||
if (foundApp || foundService || coolifyFqdn) return true;
|
if (foundApp || foundService || coolifyFqdn) return true;
|
||||||
|
@@ -46,30 +46,29 @@ export async function letsEncrypt({ domain, isCoolify = false, id = null }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!dev) {
|
if (dualCerts) {
|
||||||
if (dualCerts) {
|
await asyncExecShell(
|
||||||
await asyncExecShell(
|
`DOCKER_HOST=${host} docker run --rm --name certbot-${randomCuid} -p ${randomPort}:${randomPort} -v "coolify-letsencrypt:/etc/letsencrypt" certbot/certbot --logs-dir /etc/letsencrypt/logs certonly --standalone --preferred-challenges http --http-01-address 0.0.0.0 --http-01-port ${randomPort} -d ${nakedDomain} -d ${wwwDomain} --expand --agree-tos --non-interactive --register-unsafely-without-email ${
|
||||||
`DOCKER_HOST=${host} docker run --rm --name certbot-${randomCuid} -p ${randomPort}:${randomPort} -v "coolify-letsencrypt:/etc/letsencrypt" certbot/certbot --logs-dir /etc/letsencrypt/logs certonly --standalone --preferred-challenges http --http-01-address 0.0.0.0 --http-01-port ${randomPort} -d ${nakedDomain} -d ${wwwDomain} --expand --agree-tos --non-interactive --register-unsafely-without-email`
|
dev && '--test-cert'
|
||||||
);
|
}`
|
||||||
await asyncExecShell(
|
);
|
||||||
`DOCKER_HOST=${host} docker run --rm -v "coolify-letsencrypt:/etc/letsencrypt" -v "coolify-ssl-certs:/app/ssl" alpine:latest sh -c "test -d /etc/letsencrypt/live/${nakedDomain}/ && cat /etc/letsencrypt/live/${nakedDomain}/fullchain.pem /etc/letsencrypt/live/${nakedDomain}/privkey.pem > /app/ssl/${nakedDomain}.pem || cat /etc/letsencrypt/live/${wwwDomain}/fullchain.pem /etc/letsencrypt/live/${wwwDomain}/privkey.pem > /app/ssl/${wwwDomain}.pem"`
|
await asyncExecShell(
|
||||||
);
|
`DOCKER_HOST=${host} docker run --rm -v "coolify-letsencrypt:/etc/letsencrypt" -v "coolify-ssl-certs:/app/ssl" alpine:latest sh -c "test -d /etc/letsencrypt/live/${nakedDomain}/ && cat /etc/letsencrypt/live/${nakedDomain}/fullchain.pem /etc/letsencrypt/live/${nakedDomain}/privkey.pem > /app/ssl/${nakedDomain}.pem || cat /etc/letsencrypt/live/${wwwDomain}/fullchain.pem /etc/letsencrypt/live/${wwwDomain}/privkey.pem > /app/ssl/${wwwDomain}.pem"`
|
||||||
} else {
|
);
|
||||||
await asyncExecShell(
|
|
||||||
`DOCKER_HOST=${host} docker run --rm --name certbot-${randomCuid} -p ${randomPort}:${randomPort} -v "coolify-letsencrypt:/etc/letsencrypt" certbot/certbot --logs-dir /etc/letsencrypt/logs certonly --standalone --preferred-challenges http --http-01-address 0.0.0.0 --http-01-port ${randomPort} -d ${domain} --expand --agree-tos --non-interactive --register-unsafely-without-email`
|
|
||||||
);
|
|
||||||
await asyncExecShell(
|
|
||||||
`DOCKER_HOST=${host} docker run --rm -v "coolify-letsencrypt:/etc/letsencrypt" -v "coolify-ssl-certs:/app/ssl" alpine:latest sh -c "cat /etc/letsencrypt/live/${domain}/fullchain.pem /etc/letsencrypt/live/${domain}/privkey.pem > /app/ssl/${domain}.pem"`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
console.log({ dualCerts, host, wwwDomain, nakedDomain, domain });
|
await asyncExecShell(
|
||||||
|
`DOCKER_HOST=${host} docker run --rm --name certbot-${randomCuid} -p ${randomPort}:${randomPort} -v "coolify-letsencrypt:/etc/letsencrypt" certbot/certbot --logs-dir /etc/letsencrypt/logs certonly --standalone --preferred-challenges http --http-01-address 0.0.0.0 --http-01-port ${randomPort} -d ${domain} --expand --agree-tos --non-interactive --register-unsafely-without-email ${
|
||||||
|
dev && '--test-cert'
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
await asyncExecShell(
|
||||||
|
`DOCKER_HOST=${host} docker run --rm -v "coolify-letsencrypt:/etc/letsencrypt" -v "coolify-ssl-certs:/app/ssl" alpine:latest sh -c "cat /etc/letsencrypt/live/${domain}/fullchain.pem /etc/letsencrypt/live/${domain}/privkey.pem > /app/ssl/${domain}.pem"`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!isCoolify) {
|
if (!isCoolify) {
|
||||||
await forceSSLOnApplication({ domain });
|
await forceSSLOnApplication({ domain });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -239,6 +239,8 @@ export default async function (job) {
|
|||||||
if (stderr) console.log(stderr);
|
if (stderr) console.log(stderr);
|
||||||
saveBuildLog({ line: 'Deployment successful!', buildId, applicationId });
|
saveBuildLog({ line: 'Deployment successful!', buildId, applicationId });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
saveBuildLog({ line: error, buildId, applicationId });
|
||||||
|
sentry.captureException(error);
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -257,6 +259,7 @@ export default async function (job) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
saveBuildLog({ line: error.stdout || error, buildId, applicationId });
|
||||||
sentry.captureException(error);
|
sentry.captureException(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const found = await db.isDomainConfigured({ id, fqdn });
|
const found = await db.isDomainConfigured({ id, fqdn });
|
||||||
if (found) {
|
if (found) {
|
||||||
throw {
|
throw {
|
||||||
message: `Domain ${getDomain(fqdn)} is already configured.`
|
message: `Domain ${getDomain(fqdn).replace('www.', '')} is already configured.`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@@ -17,7 +17,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
return {
|
return {
|
||||||
status: found ? 500 : 200,
|
status: found ? 500 : 200,
|
||||||
body: {
|
body: {
|
||||||
error: found && `Domain ${getDomain(fqdn)} is already configured`
|
error: found && `Domain ${getDomain(fqdn).replace('www.', '')} is already configured`
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@@ -16,7 +16,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
return {
|
return {
|
||||||
status: found ? 500 : 200,
|
status: found ? 500 : 200,
|
||||||
body: {
|
body: {
|
||||||
error: found && `Domain ${fqdn} is already configured`
|
error: found && `Domain ${fqdn.replace('www.', '')} is already configured`
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Reference in New Issue
Block a user