Commit 249157a0 authored by 金凯强's avatar 金凯强 🎨

远程升级删除旧镜像

修改app_list
parent 940bbbd0
Pipeline #22416 passed with stage
in 25 seconds
......@@ -157,6 +157,17 @@ docker-compose -f /data/upgrade_tools_data/backup/{upgrade_no}/docker-compose.ym
# 打包镜像
self._package_images(upgrade_no, code_list_str)
# 修改app_list
docker_compose_file_dir = self.find_compose_by_upgrade_no(upgrade_no)
with open(docker_compose_file_dir, 'r', encoding='utf8') as f:
compose_content = f.read()
compose_content = re.sub('# app_list: "(.*)"', f'# app_list: "{code_list_str}"', compose_content)
with open(docker_compose_file_dir, 'w', encoding='utf8') as f:
f.write(compose_content)
for files in os.listdir(upgrade_back_up_dir):
path = os.path.join(upgrade_back_up_dir, files)
# 隐藏文件不复制
......@@ -195,6 +206,7 @@ docker-compose -f /data/upgrade_tools_data/backup/{upgrade_no}/docker-compose.ym
# 先去重
if isinstance(code_list, list):
code_list = list(set(code_list))
code_list = [item.strip() for item in code_list]
code_list_str = ' '.join(code_list)
elif code_list == '*':
code_list_str = '*'
......
......@@ -37,6 +37,9 @@ if __name__ == '__main__':
with open('/data/nginx/conf/rpc.conf', 'w')as f:
f.write(rpc_conf_content)
print('删除旧镜像')
os.system('rm *.tar -f')
with os.popen('ls | grep .tar') as f:
cmd_txt = f.read()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment