docs: make compose inventory generation deterministic

This commit is contained in:
beatz174-bit
2026-05-13 08:19:39 +10:00
parent 9c38910a67
commit d878a0f9b8
3 changed files with 6 additions and 4 deletions
+4 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import hashlib
import sys, yaml
from datetime import datetime, timezone
def md(v): return str(v).replace('|','\\|') if v is not None else ''
@@ -9,7 +9,9 @@ with open(inp) as f: c=yaml.safe_load(f) or {}
svcs=c.get('services',{}) or {}
nets=c.get('networks',{}) or {}
vols=c.get('volumes',{}) or {}
lines=["# Docker Compose Inventory","",f"Generated: {datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')}","","## Summary","","| Item | Count |","|---|---:|",f"| Services | {len(svcs)} |",f"| Networks | {len(nets)} |",f"| Volumes | {len(vols)} |","","## Services","","| Service | Container | Image | Build | Profiles | Networks | Ports | Restart |","|---|---|---|---|---|---|---|---|"]
raw=open(inp,'rb').read()
fingerprint=hashlib.sha256(raw).hexdigest()[:12]
lines=["# Docker Compose Inventory","",f"Source fingerprint: `{fingerprint}`","","## Summary","","| Item | Count |","|---|---:|",f"| Services | {len(svcs)} |",f"| Networks | {len(nets)} |",f"| Volumes | {len(vols)} |","","## Services","","| Service | Container | Image | Build | Profiles | Networks | Ports | Restart |","|---|---|---|---|---|---|---|---|"]
for n,s in sorted(svcs.items()):
build=s.get('build','')
if isinstance(build,dict): build=build.get('context','')