#!/bin/sh set -eu SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) PROJECT_DIR=$(dirname -- "$SCRIPT_DIR") cd "$PROJECT_DIR" original_ids=$(docker compose --env-file .env ps -q api) count=$(printf '%s\n' "$original_ids" | sed '/^$/d' | wc -l | tr -d ' ') if [ "$count" -lt 2 ]; then printf '%s\n' 'Rolling update requires at least two API replicas' >&2 exit 2 fi for container_id in $original_ids; do # Replace exactly one original replica and wait for the replacement before # touching the next one. Named volumes and state stores are not changed. docker stop --time 10 "$container_id" >/dev/null docker rm "$container_id" >/dev/null docker compose --env-file .env up -d --wait --wait-timeout 90 \ --no-deps --scale api=2 api >/dev/null done