#!/bin/sh set -eu compose="docker compose --env-file .env" # Add one ready replica before removing any old container. $compose up -d --scale api=3 --wait --wait-timeout 120 api python3 - <<'PY' import time, urllib.request end=time.monotonic()+60 while time.monotonic()/dev/null docker rm "$id" >/dev/null docker compose --env-file .env up -d --scale api=3 --wait --wait-timeout 120 api sleep 3 done docker compose --env-file .env up -d --scale api=2 --wait --wait-timeout 120 api