#!/usr/bin/env bash set -euo pipefail umask 077 package=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) root=$(cd "${1:?Provide the existing ECS project directory}" && pwd) cd "$root" test -f .env && test -f Dockerfile.offline && test -d wheelhouse image=hainuo-relay:0.1.0 rollback="hainuo-relay:before-notifications-$(date +%Y%m%d-%H%M%S)" docker image tag "$image" "$rollback" echo "Rollback image: $rollback" docker run --rm --user 0:0 --entrypoint python \ -v "$root:/work" -v "$package:/patch:ro" "$image" \ /patch/scripts/apply_notification_server.py --root /work --package /patch docker build --network none --pull=false -f Dockerfile.offline -t "$image" . args=(-f compose.yaml) for extra in compose.offline.yaml compose.edge-fix.yaml compose.h5.yaml compose.work.yaml compose.feishu.yaml compose.autoreg.yaml compose.userapi.yaml; do if [[ -f "$extra" ]]; then args+=(-f "$extra"); fi done # Keep existing overrides, key material, binding database and container networking. docker compose "${args[@]}" up -d --no-build --pull never --no-deps --force-recreate connector docker compose "${args[@]}" exec -T connector python -c 'import time,urllib.request for _ in range(30): try: urllib.request.urlopen("http://127.0.0.1:8000/ready",timeout=2) print("Connector ready; proceed with notification business acceptance.") break except Exception: time.sleep(1) else: raise SystemExit("Connector not ready; preserve logs and use the recorded rollback image.")' echo 'Only connector was recreated. Ready is not proof that the platform accepted a card.'