#!/usr/bin/env python3 import os,ssl,subprocess,time,urllib.request from pathlib import Path ROOT=Path(__file__).resolve().parents[1] def run(*args):subprocess.run(args,cwd=ROOT,check=True) run('python3','scripts/bootstrap.py') run('docker','compose','build','api') run('docker','compose','up','-d','--no-build','--force-recreate') # API depends_on service_completed_successfully already gates migrations. ids=subprocess.check_output(['docker','compose','ps','-a','-q','migrate'],cwd=ROOT,text=True).splitlines() assert ids, 'migration container missing' for cid in ids: result=subprocess.check_output(['docker','inspect','--format','{{.State.ExitCode}}',cid],text=True).strip();assert result=='0', 'migration failed' run('python3','scripts/bao_operator.py') ctx=ssl.create_default_context(cafile=str(ROOT/'certs/ca.crt')) port=os.environ.get('APP_PORT','8443') for _ in range(90): try: with urllib.request.urlopen('https://localhost:'+port+'/health/ready',context=ctx,timeout=2) as r: if r.status==200:print('HTTPS/mTLS application ready; certificate verification enabled.');break except OSError:pass time.sleep(1) else:raise RuntimeError('Secure ingress did not become ready')