Compare commits
2 Commits
3142e9fbd0
...
8698229b8f
| Author | SHA1 | Date | |
|---|---|---|---|
| 8698229b8f | |||
| 1c4dc3b809 |
+1
-1
@@ -3,5 +3,5 @@ WORKDIR /app
|
|||||||
RUN apt-get update && apt-get install -y curl systemd && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y curl systemd && rm -rf /var/lib/apt/lists/*
|
||||||
RUN pip install fastapi uvicorn requests-unixsocket pyyaml pytest httpx
|
RUN pip install fastapi uvicorn requests-unixsocket pyyaml pytest httpx
|
||||||
COPY app.py .
|
COPY app.py .
|
||||||
COPY tests/ ./tests/
|
#COPY tests/ ./tests/
|
||||||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
|
|||||||
@@ -439,6 +439,31 @@ def find_defined_containers():
|
|||||||
defined[name] = rel
|
defined[name] = rel
|
||||||
return defined
|
return defined
|
||||||
|
|
||||||
|
def _extract_published_ports(container: dict) -> list[str]:
|
||||||
|
"""
|
||||||
|
Normalize Podman API Ports into a stable display list:
|
||||||
|
- "127.0.0.1:8080:8000/tcp"
|
||||||
|
- "8080:8000/tcp" (if no host ip)
|
||||||
|
"""
|
||||||
|
out: list[str] = []
|
||||||
|
for p in (container.get("Ports") or []):
|
||||||
|
host_ip = p.get("host_ip") or p.get("HostIp") or ""
|
||||||
|
host_port = p.get("host_port") or p.get("HostPort")
|
||||||
|
cont_port = p.get("container_port") or p.get("ContainerPort")
|
||||||
|
proto = p.get("protocol") or p.get("Protocol") or ""
|
||||||
|
|
||||||
|
if host_port is None or cont_port is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
s = ""
|
||||||
|
if host_ip:
|
||||||
|
s += f"{host_ip}:"
|
||||||
|
s += f"{host_port}:{cont_port}"
|
||||||
|
if proto:
|
||||||
|
s += f"/{proto}"
|
||||||
|
out.append(s)
|
||||||
|
|
||||||
|
return out
|
||||||
|
|
||||||
@app.get("/containers-dashboard")
|
@app.get("/containers-dashboard")
|
||||||
def containers_dashboard():
|
def containers_dashboard():
|
||||||
@@ -449,6 +474,7 @@ def containers_dashboard():
|
|||||||
for c in real:
|
for c in real:
|
||||||
_ensure_container_status_field(c)
|
_ensure_container_status_field(c)
|
||||||
c["_dashboard_source"] = "podman"
|
c["_dashboard_source"] = "podman"
|
||||||
|
c["_dashboard_published_ports"] = _extract_published_ports(c)
|
||||||
dashboard.append(c)
|
dashboard.append(c)
|
||||||
|
|
||||||
# B) Dedup set (HOTFIX 3.3) — exact extraction, no sorting
|
# B) Dedup set (HOTFIX 3.3) — exact extraction, no sorting
|
||||||
|
|||||||
@@ -635,9 +635,8 @@
|
|||||||
const podName = c.PodName || '-';
|
const podName = c.PodName || '-';
|
||||||
const image = c.Image || c.image || '';
|
const image = c.Image || c.image || '';
|
||||||
const managed = c._dashboard_source || 'podman';
|
const managed = c._dashboard_source || 'podman';
|
||||||
const ports = (c.Ports || []).map(p =>
|
const ports = (c._dashboard_published_ports || []).join(", ")
|
||||||
`${p.host_port}:${p.container_port}`
|
|| (c.Ports || []).map(p => `${p.host_port}:${p.container_port}`).join(", ");
|
||||||
).join(", ");
|
|
||||||
return `
|
return `
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>${esc(name)}</strong></td>
|
<td><strong>${esc(name)}</strong></td>
|
||||||
|
|||||||
Reference in New Issue
Block a user