mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-07 23:15:27 +02:00
fix(settings): prevent duplicate port entries by only adding the first mapping for each target port
This commit is contained in:
@@ -372,19 +372,27 @@ export const readPorts = async (
|
|||||||
publishedPort: number;
|
publishedPort: number;
|
||||||
protocol?: string;
|
protocol?: string;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
const seenPorts = new Set<string>();
|
||||||
for (const key in parsedResult) {
|
for (const key in parsedResult) {
|
||||||
if (Object.hasOwn(parsedResult, key)) {
|
if (Object.hasOwn(parsedResult, key)) {
|
||||||
const containerPortMapppings = parsedResult[key];
|
const containerPortMapppings = parsedResult[key];
|
||||||
const protocol = key.split("/")[1];
|
const protocol = key.split("/")[1];
|
||||||
const targetPort = Number.parseInt(key.split("/")[0] ?? "0", 10);
|
const targetPort = Number.parseInt(key.split("/")[0] ?? "0", 10);
|
||||||
|
|
||||||
containerPortMapppings.forEach((mapping: any) => {
|
// Take only the first mapping to avoid duplicates (IPv4 and IPv6)
|
||||||
ports.push({
|
const firstMapping = containerPortMapppings[0];
|
||||||
targetPort: targetPort,
|
if (firstMapping) {
|
||||||
publishedPort: Number.parseInt(mapping.HostPort, 10),
|
const publishedPort = Number.parseInt(firstMapping.HostPort, 10);
|
||||||
protocol: protocol,
|
const portKey = `${targetPort}-${publishedPort}-${protocol}`;
|
||||||
});
|
if (!seenPorts.has(portKey)) {
|
||||||
});
|
seenPorts.add(portKey);
|
||||||
|
ports.push({
|
||||||
|
targetPort: targetPort,
|
||||||
|
publishedPort: publishedPort,
|
||||||
|
protocol: protocol,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ports.filter(
|
return ports.filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user