diff --git a/frontend/i18n/locales/fr.json b/frontend/i18n/locales/fr.json
index 88aa979..fdcf49d 100644
--- a/frontend/i18n/locales/fr.json
+++ b/frontend/i18n/locales/fr.json
@@ -138,6 +138,7 @@
"uptime": "Uptime",
"cpu": "CPU",
"memory": "Memoire",
+ "ports": "Ports",
"noData": "Aucune donnee disponible"
},
"deploy": {
diff --git a/frontend/pages/applications/[slug].vue b/frontend/pages/applications/[slug].vue
index a241b0e..f4c308b 100644
--- a/frontend/pages/applications/[slug].vue
+++ b/frontend/pages/applications/[slug].vue
@@ -427,7 +427,7 @@ onMounted(loadApplication)
{{ t('environments.health.title') }}
-
+
{{ t('environments.health.status') }}
({{ healthByEnvId[env.id!].memoryPercent }}%)
+
+
{{ t('environments.health.ports') }}
+
+
+ {{ p.hostPort }}:{{ p.containerPort }}
+
+
+
-
+
diff --git a/frontend/services/dto/dashboard.ts b/frontend/services/dto/dashboard.ts
index 1f2dcc1..3614284 100644
--- a/frontend/services/dto/dashboard.ts
+++ b/frontend/services/dto/dashboard.ts
@@ -16,6 +16,12 @@ type DashboardResponse = {
applications: DashboardApplication[]
}
+type PortMapping = {
+ hostPort: string
+ containerPort: string
+ protocol: string
+}
+
type EnvironmentHealth = {
status: string
version: string
@@ -24,4 +30,5 @@ type EnvironmentHealth = {
memoryUsage: string
memoryLimit: string
memoryPercent: number
+ ports: PortMapping[]
}
diff --git a/src/ApiResource/EnvironmentHealth.php b/src/ApiResource/EnvironmentHealth.php
index 1072d7d..73be6bd 100644
--- a/src/ApiResource/EnvironmentHealth.php
+++ b/src/ApiResource/EnvironmentHealth.php
@@ -26,4 +26,6 @@ final class EnvironmentHealth
public string $memoryUsage = '';
public string $memoryLimit = '';
public float $memoryPercent = 0.0;
+ /** @var list
*/
+ public array $ports = [];
}
diff --git a/src/Service/DockerService.php b/src/Service/DockerService.php
index 63b9fb8..2d8a0c0 100644
--- a/src/Service/DockerService.php
+++ b/src/Service/DockerService.php
@@ -23,7 +23,7 @@ final class DockerService
}
/**
- * @return array{status: string, image: string, version: string, startedAt: string}
+ * @return array{status: string, image: string, version: string, startedAt: string, ports: list}
*/
public function getContainerStatus(string $containerName): array
{
@@ -33,12 +33,13 @@ final class DockerService
'image' => '',
'version' => '',
'startedAt' => '',
+ 'ports' => [],
];
}
$process = new Process([
'docker', 'inspect',
- '--format', '{{.State.Status}}||{{.Config.Image}}||{{.State.StartedAt}}',
+ '--format', '{{.State.Status}}||{{.Config.Image}}||{{.State.StartedAt}}||{{json .NetworkSettings.Ports}}',
$containerName,
]);
$process->setTimeout(10);
@@ -50,10 +51,11 @@ final class DockerService
'image' => '',
'version' => '',
'startedAt' => '',
+ 'ports' => [],
];
}
- $parts = explode('||', trim($process->getOutput()));
+ $parts = explode('||', trim($process->getOutput()), 4);
if (\count($parts) < 3) {
return [
@@ -61,6 +63,7 @@ final class DockerService
'image' => '',
'version' => '',
'startedAt' => '',
+ 'ports' => [],
];
}
@@ -70,11 +73,32 @@ final class DockerService
$version = substr($image, strrpos($image, ':') + 1);
}
+ $ports = [];
+ if (isset($parts[3])) {
+ $portsJson = json_decode($parts[3], true);
+ if (\is_array($portsJson)) {
+ foreach ($portsJson as $containerPort => $bindings) {
+ if (!\is_array($bindings)) {
+ continue;
+ }
+ [$port, $protocol] = explode('/', $containerPort) + [1 => 'tcp'];
+ foreach ($bindings as $binding) {
+ $ports[] = [
+ 'hostPort' => $binding['HostPort'] ?? '',
+ 'containerPort' => $port,
+ 'protocol' => $protocol,
+ ];
+ }
+ }
+ }
+ }
+
return [
'status' => $parts[0],
'image' => $image,
'version' => $version,
'startedAt' => $parts[2],
+ 'ports' => $ports,
];
}
diff --git a/src/State/EnvironmentHealthProvider.php b/src/State/EnvironmentHealthProvider.php
index 7044798..b0f23ba 100644
--- a/src/State/EnvironmentHealthProvider.php
+++ b/src/State/EnvironmentHealthProvider.php
@@ -39,6 +39,7 @@ final readonly class EnvironmentHealthProvider implements ProviderInterface
$dto->memoryUsage = $stats['memoryUsage'];
$dto->memoryLimit = $stats['memoryLimit'];
$dto->memoryPercent = $stats['memoryPercent'];
+ $dto->ports = $status['ports'];
return $dto;
}