mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-29 22:58:49 +00:00
refactor(settings): remove unused getTraefikPorts function to streamline settings router
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
|||||||
cleanUpUnusedVolumes,
|
cleanUpUnusedVolumes,
|
||||||
DEFAULT_UPDATE_DATA,
|
DEFAULT_UPDATE_DATA,
|
||||||
execAsync,
|
execAsync,
|
||||||
execAsyncRemote,
|
|
||||||
findServerById,
|
findServerById,
|
||||||
findUserById,
|
findUserById,
|
||||||
getDokployImage,
|
getDokployImage,
|
||||||
@@ -850,56 +849,3 @@ export const settingsRouter = createTRPCRouter({
|
|||||||
return ips;
|
return ips;
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getTraefikPorts = async (serverId?: string) => {
|
|
||||||
const command = `docker container inspect --format='{{json .NetworkSettings.Ports}}' dokploy-traefik`;
|
|
||||||
try {
|
|
||||||
let stdout = "";
|
|
||||||
if (serverId) {
|
|
||||||
const result = await execAsyncRemote(serverId, command);
|
|
||||||
stdout = result.stdout;
|
|
||||||
} else if (!IS_CLOUD) {
|
|
||||||
const result = await execAsync(command);
|
|
||||||
stdout = result.stdout;
|
|
||||||
}
|
|
||||||
|
|
||||||
const portsMap = JSON.parse(stdout.trim());
|
|
||||||
const additionalPorts: Array<{
|
|
||||||
targetPort: number;
|
|
||||||
publishedPort: number;
|
|
||||||
}> = [];
|
|
||||||
|
|
||||||
// Convert the Docker container port format to our expected format
|
|
||||||
for (const [containerPort, bindings] of Object.entries(portsMap)) {
|
|
||||||
if (!bindings) continue;
|
|
||||||
|
|
||||||
const [port = ""] = containerPort.split("/");
|
|
||||||
if (!port) continue;
|
|
||||||
|
|
||||||
const targetPortNum = Number.parseInt(port, 10);
|
|
||||||
if (Number.isNaN(targetPortNum)) continue;
|
|
||||||
|
|
||||||
// Skip default ports
|
|
||||||
if ([80, 443].includes(targetPortNum)) continue;
|
|
||||||
|
|
||||||
for (const binding of bindings as Array<{ HostPort: string }>) {
|
|
||||||
if (!binding.HostPort) continue;
|
|
||||||
const publishedPort = Number.parseInt(binding.HostPort, 10);
|
|
||||||
if (Number.isNaN(publishedPort)) continue;
|
|
||||||
|
|
||||||
additionalPorts.push({
|
|
||||||
targetPort: targetPortNum,
|
|
||||||
publishedPort,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return additionalPorts;
|
|
||||||
} catch (error) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "INTERNAL_SERVER_ERROR",
|
|
||||||
message: "Failed to get Traefik ports",
|
|
||||||
cause: error,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user