2022-06-20 02:06:30 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2022-06-20 02:35:24 +00:00
|
|
|
import subprocess
|
|
|
|
from datetime import date
|
2022-06-20 02:06:30 +00:00
|
|
|
|
|
|
|
if len(sys.argv) != 3:
|
|
|
|
print("Invalid number of arguments\n")
|
|
|
|
exit(1)
|
|
|
|
|
2022-06-20 02:16:26 +00:00
|
|
|
path = os.path.abspath(sys.argv[1])
|
|
|
|
spec_file = os.path.abspath(sys.argv[2])
|
2022-06-20 02:06:30 +00:00
|
|
|
|
|
|
|
with open(spec_file,"r") as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
|
|
|
|
|
2022-06-20 02:35:24 +00:00
|
|
|
print(">>>>>>>>>> docker_update.py@" + date.today() + " <<<<<<<<<<")
|
|
|
|
|
2022-06-20 02:06:30 +00:00
|
|
|
for line in lines:
|
|
|
|
s = line.strip()
|
2022-06-20 02:27:50 +00:00
|
|
|
if s.startswith("#"):
|
|
|
|
continue
|
2022-06-20 02:13:09 +00:00
|
|
|
fullpath = os.path.join(path, s)
|
2022-06-20 02:21:44 +00:00
|
|
|
if os.path.isdir(fullpath) and ("docker-compose.yml" in os.listdir(fullpath)):
|
|
|
|
fullpath = os.path.join(fullpath, "docker-compose.yml")
|
2022-06-20 02:13:09 +00:00
|
|
|
print("========= Processing " + fullpath + " =========")
|
2022-06-20 02:35:24 +00:00
|
|
|
print(subprocess.check_output("docker-compose -f " + fullpath + " pull", shell=True))
|
|
|
|
print(subprocess.check_output("docker-compose -f " + fullpath + " up -d", shell=True))
|
2022-06-20 02:13:09 +00:00
|
|
|
else:
|
|
|
|
print("========= Skipping " + fullpath + ": invalid dir or docker-compos.yml =========")
|
|
|
|
|
2022-06-20 02:06:30 +00:00
|
|
|
|
|
|
|
print("========== CLEANING UP ==========")
|
2022-06-20 02:35:24 +00:00
|
|
|
print(subprocess.check_output("docker system prune -af", shell=True))
|
2022-06-20 02:06:30 +00:00
|
|
|
|
2022-06-20 02:35:24 +00:00
|
|
|
print("Docker update complete!\n")
|