mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-09-14 11:06:15 +05:00
fix(compose): clean domain labels across services
This commit is contained in:
parent
f14f12c778
commit
67fa8e4104
@ -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([
|
||||
[
|
||||
"docker-compose",
|
||||
|
||||
@ -224,24 +224,21 @@ export const addDomainToCompose = async (
|
||||
result = randomized;
|
||||
}
|
||||
|
||||
for (const domain of domains.filter((d) => !d.enabled)) {
|
||||
if (!domain.serviceName) continue;
|
||||
|
||||
const service = result.services?.[domain.serviceName];
|
||||
if (!service) continue;
|
||||
|
||||
if (compose.composeType === "docker-compose") {
|
||||
service.labels = removeDomainLabels(
|
||||
service.labels,
|
||||
appName,
|
||||
domain.uniqueConfigKey,
|
||||
);
|
||||
} else if (service.deploy) {
|
||||
service.deploy.labels = removeDomainLabels(
|
||||
service.deploy.labels,
|
||||
appName,
|
||||
domain.uniqueConfigKey,
|
||||
);
|
||||
for (const domain of domains) {
|
||||
for (const service of Object.values(result.services ?? {})) {
|
||||
if (compose.composeType === "docker-compose") {
|
||||
service.labels = removeDomainLabels(
|
||||
service.labels,
|
||||
appName,
|
||||
domain.uniqueConfigKey,
|
||||
);
|
||||
} else if (service.deploy) {
|
||||
service.deploy.labels = removeDomainLabels(
|
||||
service.deploy.labels,
|
||||
appName,
|
||||
domain.uniqueConfigKey,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user