wait_healthy() {
local container="$1" timeout="${2:-60}"
local start; start=$(date +%s)
while true; do
local status
status="$(docker inspect -f '{{.State.Health.Status}}' "$container" 2>/dev/null || echo "missing")"
case "$status" in
healthy) echo "$container is healthy"; return 0 ;;
unhealthy) echo "$container is unhealthy" >&2; return 1 ;;
esac
if (( $(date +%s) - start > timeout )); then
echo "Timeout waiting for $container after ${timeout}s (last: $status)" >&2
return 1
fi
sleep 1
done
}
wait_healthy app-db 60 && rails db:migrate
Create a free account and build your private vault. Share publicly whenever you want.