mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-03 10:42:16 +00:00
Merge pull request #3635 from Dokploy/3313-traefik-loses-all-bridge-network-connections-when-modifying-port-mappings-or-toggling-dashboard
feat(traefik): implement reconnectServicesToTraefik function
This commit is contained in:
@@ -4,7 +4,9 @@ import {
|
|||||||
execAsync,
|
execAsync,
|
||||||
execAsyncRemote,
|
execAsyncRemote,
|
||||||
} from "@dokploy/server/utils/process/execAsync";
|
} from "@dokploy/server/utils/process/execAsync";
|
||||||
|
import { and, eq } from "drizzle-orm";
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
|
import { compose } from "../db/schema";
|
||||||
import {
|
import {
|
||||||
initializeStandaloneTraefik,
|
initializeStandaloneTraefik,
|
||||||
initializeTraefikService,
|
initializeTraefikService,
|
||||||
@@ -438,13 +440,40 @@ export const writeTraefikSetup = async (input: TraefikOptions) => {
|
|||||||
additionalPorts: input.additionalPorts,
|
additionalPorts: input.additionalPorts,
|
||||||
serverId: input.serverId,
|
serverId: input.serverId,
|
||||||
});
|
});
|
||||||
|
await reconnectServicesToTraefik(input.serverId);
|
||||||
} else if (resourceType === "standalone") {
|
} else if (resourceType === "standalone") {
|
||||||
await initializeStandaloneTraefik({
|
await initializeStandaloneTraefik({
|
||||||
env: input.env,
|
env: input.env,
|
||||||
additionalPorts: input.additionalPorts,
|
additionalPorts: input.additionalPorts,
|
||||||
serverId: input.serverId,
|
serverId: input.serverId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await reconnectServicesToTraefik(input.serverId);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Traefik resource type not found");
|
throw new Error("Traefik resource type not found");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const reconnectServicesToTraefik = async (serverId?: string) => {
|
||||||
|
const composeResult = await db?.query.compose.findMany({
|
||||||
|
where: and(
|
||||||
|
...(serverId ? [eq(compose.serverId, serverId)] : []),
|
||||||
|
eq(compose.isolatedDeployment, true),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!composeResult) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let commands = "";
|
||||||
|
|
||||||
|
for (const compose of composeResult) {
|
||||||
|
commands += `docker network connect ${compose.appName} $(docker ps --filter "name=dokploy-traefik" -q) >/dev/null 2>&1\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serverId) {
|
||||||
|
await execAsyncRemote(serverId, commands);
|
||||||
|
} else {
|
||||||
|
await execAsync(commands);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user