mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-14 00:41:06 +01:00
improved rebuild performance
This commit is contained in:
parent
a94cf8d8c2
commit
d61039d3a2
@ -21,9 +21,24 @@ def git_pull(directory):
|
|||||||
else:
|
else:
|
||||||
print("Repository is already up to date.")
|
print("Repository is already up to date.")
|
||||||
|
|
||||||
|
def get_image_digests():
|
||||||
|
images_output = subprocess.check_output('docker-compose images --digests', shell=True).decode().strip()
|
||||||
|
image_lines = images_output.splitlines()
|
||||||
|
return {line.split()[0]: line.split()[2] for line in image_lines if line}
|
||||||
|
|
||||||
def update_docker(directory):
|
def update_docker(directory):
|
||||||
print("Pulling docker images and rebuilding containers.")
|
print(f"Checking for updates to Docker images in {directory}.")
|
||||||
run_command("docker-compose pull && docker-compose up -d --build --force-recreate")
|
os.chdir(directory)
|
||||||
|
before_digests = get_image_digests()
|
||||||
|
print("Pulling docker images.")
|
||||||
|
run_command("docker-compose pull")
|
||||||
|
after_digests = get_image_digests()
|
||||||
|
|
||||||
|
if before_digests != after_digests:
|
||||||
|
print("Changes detected in image digests. Rebuilding containers.")
|
||||||
|
run_command("docker-compose up -d --build --force-recreate")
|
||||||
|
else:
|
||||||
|
print("Docker images are up to date. No rebuild necessary.")
|
||||||
|
|
||||||
def update_nextcloud(directory):
|
def update_nextcloud(directory):
|
||||||
print("Updating Nextcloud apps.")
|
print("Updating Nextcloud apps.")
|
||||||
|
Loading…
Reference in New Issue
Block a user