fix(deploy): 恢复已有覆盖文件中的目标镜像

This commit is contained in:
easyai02
2026-10-09 03:29:45 +08:00
parent f01d36d2b8
commit 571e8c305b
2 changed files with 21 additions and 1 deletions
+12
View File
@@ -102,6 +102,18 @@ for restore in ('', 'easyai-web', 'redis', 'ws-gateway'):
newest = max(backups, key=lambda p: p.stat().st_mtime)
assert (newest / 'data/deployment-config/legacy-compose.json').read_bytes() == previous_override
assert (newest / 'data/deployment-config/legacy-compose.json').stat().st_mode & 0o077 == 0
if not restore:
# Main is clean, but an existing override still pins the web image.
# Explicit restoration must act on that override and be idempotent.
restoration_env = {**env, 'UPDATE_RESTORE_REPOSITORY_IMAGES': 'easyai-web'}
checked(['python3', str(prepare), str(root)], root, restoration_env)
config = json.loads(checked(['docker', 'compose', '--env-file', '.env', 'config', '--format', 'json'], root))
assert config['services']['easyai-web']['image'] == 'repository-web:latest'
assert config['services']['redis']['image'] == 'redis:6.2'
assert config['services']['easyai-server']['environment']['LOCAL_SETTING'] == 'second-custom'
assert len(list((root / 'data/deployment-backups').glob('legacy-update-*'))) == 3
checked(['python3', str(prepare), str(root)], root, restoration_env)
assert len(list((root / 'data/deployment-backups').glob('legacy-update-*'))) == 3
for mode, adopt in (('image', '1'), ('full', '0')):
env = {**os.environ, 'UPDATE_MODE': mode, 'UPDATE_ADOPT_LEGACY_CONFIG': adopt, 'UPDATE_RESTORE_REPOSITORY_IMAGES': 'easyai-web'}