Files
caiwuzongzhang/deploy/rollback.sh
T

20 lines
757 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 回滚:回到指定镜像标签(或最近一次可用镜像)。
# 用法:./rollback.sh <tag> 例:./rollback.sh f5e0915
# 数据库与 files/ 原始证据不受影响;如需回退数据,见 deploy/README.md「数据恢复」。
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
TAG="${1:-}"
if [[ -z "$TAG" ]]; then
echo "用法:./rollback.sh <镜像tag>(可用 tag 见 docker images caiwuzongzhang" >&2
exit 1
fi
if ! docker image inspect "caiwuzongzhang:$TAG" >/dev/null 2>&1; then
echo "镜像 caiwuzongzhang:$TAG 不存在。" >&2
exit 1
fi
TAG="$TAG" docker compose -f compose.yaml down
TAG="$TAG" docker compose -f compose.yaml up -d
echo "已回滚到 caiwuzongzhang:$TAG"