mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-28 07:52:14 +00:00
fix(compose): clean domain labels across services
This commit is contained in:
@@ -139,6 +139,55 @@ describe("addDomainToCompose enabled filtering", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
"docker-compose",
|
||||||
|
`services:
|
||||||
|
legacy:
|
||||||
|
image: frigate
|
||||||
|
labels:
|
||||||
|
- traefik.http.routers.test-app-1-web.rule=Host(\`frigate.example.com\`)
|
||||||
|
- traefik.http.services.test-app-1-web.loadbalancer.server.port=8971
|
||||||
|
- custom.label=preserved
|
||||||
|
frigate:
|
||||||
|
image: frigate
|
||||||
|
`,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"stack",
|
||||||
|
`services:
|
||||||
|
legacy:
|
||||||
|
image: frigate
|
||||||
|
deploy:
|
||||||
|
labels:
|
||||||
|
- traefik.http.routers.test-app-1-web.rule=Host(\`frigate.example.com\`)
|
||||||
|
- traefik.http.services.test-app-1-web.loadbalancer.server.port=8971
|
||||||
|
- custom.label=preserved
|
||||||
|
frigate:
|
||||||
|
image: frigate
|
||||||
|
`,
|
||||||
|
],
|
||||||
|
] as const)(
|
||||||
|
"removes stale labels from the previous %s service after reassignment",
|
||||||
|
async (composeType, staleComposeYaml) => {
|
||||||
|
composeYaml = staleComposeYaml;
|
||||||
|
|
||||||
|
const result = await addDomainToCompose({ ...baseCompose, composeType }, [
|
||||||
|
{ ...baseDomain, serviceName: "frigate", enabled: false },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const previousService = result?.services?.legacy;
|
||||||
|
const labels =
|
||||||
|
composeType === "docker-compose"
|
||||||
|
? previousService?.labels
|
||||||
|
: previousService?.deploy?.labels;
|
||||||
|
expect(labels).toContain("custom.label=preserved");
|
||||||
|
expect(
|
||||||
|
(labels as string[]).some((label) => label.includes("test-app-1")),
|
||||||
|
).toBe(false);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
"docker-compose",
|
"docker-compose",
|
||||||
|
|||||||
@@ -224,24 +224,21 @@ export const addDomainToCompose = async (
|
|||||||
result = randomized;
|
result = randomized;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const domain of domains.filter((d) => !d.enabled)) {
|
for (const domain of domains) {
|
||||||
if (!domain.serviceName) continue;
|
for (const service of Object.values(result.services ?? {})) {
|
||||||
|
if (compose.composeType === "docker-compose") {
|
||||||
const service = result.services?.[domain.serviceName];
|
service.labels = removeDomainLabels(
|
||||||
if (!service) continue;
|
service.labels,
|
||||||
|
appName,
|
||||||
if (compose.composeType === "docker-compose") {
|
domain.uniqueConfigKey,
|
||||||
service.labels = removeDomainLabels(
|
);
|
||||||
service.labels,
|
} else if (service.deploy) {
|
||||||
appName,
|
service.deploy.labels = removeDomainLabels(
|
||||||
domain.uniqueConfigKey,
|
service.deploy.labels,
|
||||||
);
|
appName,
|
||||||
} else if (service.deploy) {
|
domain.uniqueConfigKey,
|
||||||
service.deploy.labels = removeDomainLabels(
|
);
|
||||||
service.deploy.labels,
|
}
|
||||||
appName,
|
|
||||||
domain.uniqueConfigKey,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user