forked from mtusi2026/mtusi2026lab4
19 lines
659 B
Bash
Executable File
19 lines
659 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
N=2
|
|
export APP_VERSION="${APP_VERSION:-v$(date +%s)}"
|
|
wait_healthy() {
|
|
until [ "$(docker compose ps -q api | xargs docker inspect -f '{{.State.Health.Status}}' | grep -c '^healthy$')" = "$1" ]; do sleep 1; done
|
|
}
|
|
docker compose build api
|
|
for old in $(docker compose ps -q api); do
|
|
docker compose up -d --no-deps --no-recreate --scale api=$((N+1)) api
|
|
wait_healthy $((N+1))
|
|
sleep 5 # LB: rise 2 + обновление DNS
|
|
echo "$(date +%T) replacing $(docker inspect -f '{{.Name}}' "$old")"
|
|
docker stop -t 20 "$old" >/dev/null
|
|
docker rm "$old" >/dev/null
|
|
done
|
|
wait_healthy $N
|
|
echo "$(date +%T) done, APP_VERSION=$APP_VERSION"
|