fix(containers): sync ports after start or restart

This commit is contained in:
KodekaTeam committed 2026-06-20 00:21:20 +07:00
1 parent a2c029a593
commit dddb6807cc
1 file changed
+30 -11
+30 -11
View File
@@ -487,7 +487,11 @@ function extractComposePublishedHostPorts(composeContent?: string | null) {
return []; return [];
} }
if (typeof parsed !== "object" || parsed === null || !("services" in parsed)) { if (
typeof parsed !== "object" ||
parsed === null ||
!("services" in parsed)
) {
return []; return [];
} }
@@ -2853,8 +2857,9 @@ export async function containerRoutes(app: FastifyInstance) {
const shouldValidateHostPorts = const shouldValidateHostPorts =
collectRequestedHostPorts(body.data).length > 0; collectRequestedHostPorts(body.data).length > 0;
const shouldValidateContainerName = const shouldValidateContainerName = shouldValidateRequestedContainerName(
shouldValidateRequestedContainerName(body.data); body.data,
);
if (shouldValidateHostPorts || shouldValidateContainerName) { if (shouldValidateHostPorts || shouldValidateContainerName) {
try { try {
@@ -3283,6 +3288,23 @@ export async function containerRoutes(app: FastifyInstance) {
}, },
include: { server: { select: { name: true, ip: true } } }, include: { server: { select: { name: true, ip: true } } },
}); });
if (action === "start" || action === "restart") {
await syncContainersForServers(
[container.server],
req.userId,
(event) => recordDockerCommandTiming(app, event),
);
updatedContainer =
(await prisma.container.findFirst({
where: {
id,
server: { organizationId: req.organizationId! },
},
include: { server: { select: { name: true, ip: true } } },
})) ?? updatedContainer;
}
} }
await auditLog({ await auditLog({
@@ -3517,8 +3539,10 @@ export async function containerRoutes(app: FastifyInstance) {
), ),
}); });
await syncContainersForServers([container.server], req.userId, (event) => await syncContainersForServers(
recordDockerCommandTiming(app, event), [container.server],
req.userId,
(event) => recordDockerCommandTiming(app, event),
); );
const serverContainers = await prisma.container.findMany({ const serverContainers = await prisma.container.findMany({
@@ -3624,12 +3648,7 @@ export async function containerRoutes(app: FastifyInstance) {
serverName: container.server.name, serverName: container.server.name,
containerId: container.id, containerId: container.id,
}, },
() => () => ssh.dockerLogs(container.server, runtimeId, parseInt(lines)),
ssh.dockerLogs(
container.server,
runtimeId,
parseInt(lines),
),
); );
return reply.send({ return reply.send({
success: true, success: true,