mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-25 22:21:04 +01:00
implemented an more general digest approach
This commit is contained in:
parent
4b32bd1e5d
commit
9b0d744052
@ -21,18 +21,21 @@ def git_pull(directory):
|
|||||||
else:
|
else:
|
||||||
print("Repository is already up to date.")
|
print("Repository is already up to date.")
|
||||||
|
|
||||||
def get_image_digests():
|
def get_image_digests(directory):
|
||||||
images_output = subprocess.check_output('docker-compose images --digests', shell=True).decode().strip()
|
compose_project = os.path.basename(directory)
|
||||||
image_lines = images_output.splitlines()
|
images_output = subprocess.check_output(
|
||||||
return {line.split()[0]: line.split()[2] for line in image_lines if line}
|
f'docker images --format "{{{{.Repository}}}}:{{{{.Tag}}}}@{{{{.Digest}}}}" | grep {compose_project}',
|
||||||
|
shell=True
|
||||||
|
).decode().strip()
|
||||||
|
return dict(line.split('@') for line in images_output.splitlines() if line)
|
||||||
|
|
||||||
def update_docker(directory):
|
def update_docker(directory):
|
||||||
print(f"Checking for updates to Docker images in {directory}.")
|
print(f"Checking for updates to Docker images in {directory}.")
|
||||||
os.chdir(directory)
|
os.chdir(directory)
|
||||||
before_digests = get_image_digests()
|
before_digests = get_image_digests(directory)
|
||||||
print("Pulling docker images.")
|
print("Pulling docker images.")
|
||||||
run_command("docker-compose pull")
|
run_command("docker-compose pull")
|
||||||
after_digests = get_image_digests()
|
after_digests = get_image_digests(directory)
|
||||||
|
|
||||||
if before_digests != after_digests:
|
if before_digests != after_digests:
|
||||||
print("Changes detected in image digests. Rebuilding containers.")
|
print("Changes detected in image digests. Rebuilding containers.")
|
||||||
|
Loading…
Reference in New Issue
Block a user