mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02:00
refactor(domain): simplify custom entrypoint checks in Docker and Traefik utilities
- Updated conditional checks for customEntrypoint to use a more concise syntax. - Ensured consistent handling of HTTPS configurations across domain management functions. - Improved code readability and maintainability by streamlining logic in addDomainToCompose and manageDomain functions.
This commit is contained in:
@@ -177,7 +177,7 @@ export const addDomainToCompose = async (
|
|||||||
domain,
|
domain,
|
||||||
domain.customEntrypoint || "web",
|
domain.customEntrypoint || "web",
|
||||||
);
|
);
|
||||||
if (domain.customEntrypoint == null && https) {
|
if (!domain.customEntrypoint && https) {
|
||||||
const httpsLabels = createDomainLabels(appName, domain, "websecure");
|
const httpsLabels = createDomainLabels(appName, domain, "websecure");
|
||||||
httpLabels.push(...httpsLabels);
|
httpLabels.push(...httpsLabels);
|
||||||
}
|
}
|
||||||
@@ -289,7 +289,7 @@ export const createDomainLabels = (
|
|||||||
if (stripPath && path && path !== "/") {
|
if (stripPath && path && path !== "/") {
|
||||||
const middlewareName = `stripprefix-${appName}-${uniqueConfigKey}`;
|
const middlewareName = `stripprefix-${appName}-${uniqueConfigKey}`;
|
||||||
// Only define middleware once (on web entrypoint)
|
// Only define middleware once (on web entrypoint)
|
||||||
if (entrypoint === "web" || customEntrypoint != null) {
|
if (entrypoint === "web" || customEntrypoint) {
|
||||||
labels.push(
|
labels.push(
|
||||||
`traefik.http.middlewares.${middlewareName}.stripprefix.prefixes=${path}`,
|
`traefik.http.middlewares.${middlewareName}.stripprefix.prefixes=${path}`,
|
||||||
);
|
);
|
||||||
@@ -301,7 +301,7 @@ export const createDomainLabels = (
|
|||||||
if (internalPath && internalPath !== "/" && internalPath.startsWith("/")) {
|
if (internalPath && internalPath !== "/" && internalPath.startsWith("/")) {
|
||||||
const middlewareName = `addprefix-${appName}-${uniqueConfigKey}`;
|
const middlewareName = `addprefix-${appName}-${uniqueConfigKey}`;
|
||||||
// Only define middleware once (on web entrypoint)
|
// Only define middleware once (on web entrypoint)
|
||||||
if (entrypoint === "web" || customEntrypoint != null) {
|
if (entrypoint === "web" || customEntrypoint) {
|
||||||
labels.push(
|
labels.push(
|
||||||
`traefik.http.middlewares.${middlewareName}.addprefix.prefix=${internalPath}`,
|
`traefik.http.middlewares.${middlewareName}.addprefix.prefix=${internalPath}`,
|
||||||
);
|
);
|
||||||
@@ -317,7 +317,7 @@ export const createDomainLabels = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add TLS configuration for websecure
|
// Add TLS configuration for websecure
|
||||||
if (entrypoint === "websecure" || (customEntrypoint != null && https)) {
|
if (entrypoint === "websecure" || (customEntrypoint && https)) {
|
||||||
if (certificateType === "letsencrypt") {
|
if (certificateType === "letsencrypt") {
|
||||||
labels.push(
|
labels.push(
|
||||||
`traefik.http.routers.${routerName}.tls.certresolver=letsencrypt`,
|
`traefik.http.routers.${routerName}.tls.certresolver=letsencrypt`,
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export const manageDomain = async (app: ApplicationNested, domain: Domain) => {
|
|||||||
domain.customEntrypoint || "web",
|
domain.customEntrypoint || "web",
|
||||||
);
|
);
|
||||||
|
|
||||||
if (domain.customEntrypoint == null && domain.https) {
|
if (!domain.customEntrypoint && domain.https) {
|
||||||
config.http.routers[routerNameSecure] = await createRouterConfig(
|
config.http.routers[routerNameSecure] = await createRouterConfig(
|
||||||
app,
|
app,
|
||||||
domain,
|
domain,
|
||||||
@@ -181,7 +181,7 @@ export const createRouterConfig = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entryPoint === "websecure" || (customEntrypoint != null && https)) {
|
if (entryPoint === "websecure" || (customEntrypoint && https)) {
|
||||||
if (certificateType === "letsencrypt") {
|
if (certificateType === "letsencrypt") {
|
||||||
routerConfig.tls = { certResolver: "letsencrypt" };
|
routerConfig.tls = { certResolver: "letsencrypt" };
|
||||||
} else if (certificateType === "custom" && domain.customCertResolver) {
|
} else if (certificateType === "custom" && domain.customCertResolver) {
|
||||||
|
|||||||
Reference in New Issue
Block a user