mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Merge pull request #44 from Dokploy/38-removing-domain-not-working
fix: prevent to have empty traefik config in order to prevent domain…
This commit is contained in:
@@ -52,7 +52,7 @@ export const domainRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
const domain = await findDomainById(input.domainId);
|
const domain = await findDomainById(input.domainId);
|
||||||
const result = await removeDomainById(input.domainId);
|
const result = await removeDomainById(input.domainId);
|
||||||
removeDomain(domain.application.appName, domain.uniqueConfigKey);
|
await removeDomain(domain.application.appName, domain.uniqueConfigKey);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -36,9 +36,8 @@ export const createApplication = async (
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createTraefikConfig(newApplication.appName);
|
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "development") {
|
if (process.env.NODE_ENV === "development") {
|
||||||
|
createTraefikConfig(newApplication.appName);
|
||||||
await tx.insert(domains).values({
|
await tx.insert(domains).values({
|
||||||
applicationId: newApplication.applicationId,
|
applicationId: newApplication.applicationId,
|
||||||
host: `${newApplication.appName}.docker.localhost`,
|
host: `${newApplication.appName}.docker.localhost`,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
createServiceConfig,
|
createServiceConfig,
|
||||||
loadOrCreateConfig,
|
loadOrCreateConfig,
|
||||||
|
removeTraefikConfig,
|
||||||
writeTraefikConfig,
|
writeTraefikConfig,
|
||||||
} from "./application";
|
} from "./application";
|
||||||
import type { ApplicationNested } from "../builders";
|
import type { ApplicationNested } from "../builders";
|
||||||
@@ -23,7 +24,7 @@ export const manageDomain = async (app: ApplicationNested, domain: Domain) => {
|
|||||||
writeTraefikConfig(config, appName);
|
writeTraefikConfig(config, appName);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const removeDomain = (appName: string, uniqueKey: number) => {
|
export const removeDomain = async (appName: string, uniqueKey: number) => {
|
||||||
const config: FileConfig = loadOrCreateConfig(appName);
|
const config: FileConfig = loadOrCreateConfig(appName);
|
||||||
|
|
||||||
const routerKey = `${appName}-router-${uniqueKey}`;
|
const routerKey = `${appName}-router-${uniqueKey}`;
|
||||||
@@ -35,7 +36,15 @@ export const removeDomain = (appName: string, uniqueKey: number) => {
|
|||||||
delete config.http.services[serviceKey];
|
delete config.http.services[serviceKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
writeTraefikConfig(config, appName);
|
// verify if is the last router if so we delete the router
|
||||||
|
if (
|
||||||
|
config?.http?.routers &&
|
||||||
|
Object.keys(config?.http?.routers).length === 0
|
||||||
|
) {
|
||||||
|
await removeTraefikConfig(appName);
|
||||||
|
} else {
|
||||||
|
writeTraefikConfig(config, appName);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createRouterConfig = async (
|
export const createRouterConfig = async (
|
||||||
|
|||||||
Reference in New Issue
Block a user