#!/usr/bin/env python3 """Merge this project's HTTP registry into a selected daemon JSON file.""" import json from pathlib import Path import shutil import sys if len(sys.argv) != 2: sys.exit('Usage: python3 ci/runner/configure-docker.py ') path = Path(sys.argv[1]).expanduser() data = json.loads(path.read_text()) if path.exists() else {} registries = data.setdefault('insecure-registries', []) if not isinstance(registries, list): sys.exit('Existing insecure-registries must be an array; configuration left unchanged') if '192.168.2.28:3000' in registries: print('Internal registry already configured; no change') sys.exit(0) registries.append('192.168.2.28:3000') path.parent.mkdir(parents=True, exist_ok=True) if path.exists(): backup = path.with_name(path.name + '.before-agiledancers') if not backup.exists(): shutil.copy2(path, backup) # Write in the same directory, then replace atomically. temporary = path.with_name(path.name + '.agiledancers.tmp') with temporary.open('x') as output: json.dump(data, output, indent=2) output.write('\n') if path.exists(): shutil.copymode(path, temporary) temporary.replace(path) print('Internal registry added; restart/apply Docker Engine configuration to activate')