#!/usr/bin/env python3 """Сводка `docker compose config`: опубликованные порты, container_name, лимиты, какие секреты у какого сервиса. Значений секретов в конфигурации нет (только пути к файлам), поэтому вывод можно класть в evidence. python scripts/compose_summary.py > evidence/compose-config.txt """ import json import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[1] config = json.loads(subprocess.run(["docker", "compose", "config", "--format", "json"], cwd=ROOT, check=True, capture_output=True, text=True).stdout) for name, service in config["services"].items(): ports = [f"{p.get('host_ip', '0.0.0.0')}:{p.get('published')}->{p.get('target')}" for p in service.get("ports", [])] limits = service.get("deploy", {}).get("resources", {}).get("limits", {}) print(f"{name}: image={service.get('image')} replicas={service.get('deploy', {}).get('replicas', 1)} " f"published_ports={ports} container_name={service.get('container_name')} " f"limits={{cpus: {limits.get('cpus')}, memory: {limits.get('memory')}, pids: {limits.get('pids')}}} " f"secrets={[s['source'] for s in service.get('secrets', [])]}") env = service.get("environment") or {} if "MINIO_BROWSER" in env: print(f" MINIO_BROWSER={env['MINIO_BROWSER']}") print("volumes:", sorted(config.get("volumes", {})))