Files
mtusi2026lab3/scripts/rolling-update.sh
T

15 lines
474 B
Bash
Executable File

#!/bin/sh
# Sequential replacement; never stop the surviving healthy replica.
set -eu
cd "$(dirname "$0")/.."
: "${API_IMAGE:?Set API_IMAGE to the already built target image}"
export API_IMAGE
ids=$(docker compose ps -q api)
for id in $ids; do
python3 scripts/wait_replicas.py 2
docker stop --time 8 "$id" >/dev/null
docker rm "$id" >/dev/null
docker compose up -d --no-deps --no-recreate --scale api=2 --wait api
python3 scripts/wait_replicas.py 2
done