forked from wangbo/easyai
fix(release): 按服务核验 Compose 固定镜像并保留线上修复
This commit is contained in:
@@ -58,11 +58,22 @@ apply_application_versions() {
|
||||
}
|
||||
|
||||
verify_application_version_images() {
|
||||
local file="$1" compose="$2" service key option image version actual
|
||||
local file="$1" compose="$2" service key option image version actual configuration
|
||||
while read -r service key option image; do
|
||||
application_selected "$service" || continue
|
||||
version="$(read_env_value "$file" "$key")"
|
||||
actual="$(sudo $compose config --images "$service")" || return 1
|
||||
# --images SERVICE includes dependency images on Compose 5. Read the
|
||||
# selected service from normalized config instead of comparing the list.
|
||||
configuration="$(sudo $compose config --format json "$service")" || return 1
|
||||
actual="$(printf '%s' "$configuration" | python3 -c '
|
||||
import json, sys
|
||||
try:
|
||||
image = json.load(sys.stdin)["services"][sys.argv[1]]["image"]
|
||||
if not isinstance(image, str): raise ValueError()
|
||||
print(image)
|
||||
except (ValueError, KeyError, TypeError):
|
||||
raise SystemExit("无法读取应用的有效镜像定义;尚未拉取或重建服务")
|
||||
' "$service")" || return 1
|
||||
if [ "$actual" != "$image:$version" ]; then
|
||||
echo "❌ $service 的有效镜像未使用 .env 中的固定版本 $key=$version;请通过部署仓库的受控迁移恢复镜像定义,尚未拉取或重建服务" >&2
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user