From 9b41dbdcb2c810804417b9ffc4e74a7b3e534ac2 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 14 Nov 2023 13:33:14 +0100 Subject: initial commit --- .local/bin/docker-compose-update | 4 ++++ .local/bin/docker-compose-update-all | 23 +++++++++++++++++++++++ .local/bin/update | 13 +++++++++++++ 3 files changed, 40 insertions(+) create mode 100755 .local/bin/docker-compose-update create mode 100755 .local/bin/docker-compose-update-all create mode 100755 .local/bin/update (limited to '.local') diff --git a/.local/bin/docker-compose-update b/.local/bin/docker-compose-update new file mode 100755 index 0000000..ba76da1 --- /dev/null +++ b/.local/bin/docker-compose-update @@ -0,0 +1,4 @@ +docker compose down +docker compose build +docker compose pull +docker compose up -d $@ diff --git a/.local/bin/docker-compose-update-all b/.local/bin/docker-compose-update-all new file mode 100755 index 0000000..99db85f --- /dev/null +++ b/.local/bin/docker-compose-update-all @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +import sys, os +import subprocess + + +process_docker_ps = subprocess.run(['docker', 'ps', '-q'], stdout=subprocess.PIPE) + +container_ids = process_docker_ps.stdout.decode('utf-8').split('\n') + +docker_compose_project_paths = [] +for id in container_ids: + if id: + process_docker_inspect = subprocess.run(['docker', 'inspect', '--format', '{{ index .Config.Labels "com.docker.compose.project.working_dir" }}', id], stdout=subprocess.PIPE) + docker_compose_project_paths.append(process_docker_inspect.stdout.decode('utf-8').strip()) + +docker_compose_project_paths = set(docker_compose_project_paths) + +for path in docker_compose_project_paths: + subprocess.run(['docker', 'compose', 'down'], cwd=path) + subprocess.run(['docker', 'compose', 'build'], cwd=path) + subprocess.run(['docker', 'compose', 'pull'], cwd=path) + subprocess.Popen(['docker', 'compose', 'up', '-d'], cwd=path) diff --git a/.local/bin/update b/.local/bin/update new file mode 100755 index 0000000..3fc5067 --- /dev/null +++ b/.local/bin/update @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import sys, os +import subprocess + + +# apt +subprocess.run(["sudo", "apt", "update"]) +subprocess.run(["sudo", "apt", "upgrade", "-y"]) + + +# docker +subprocess.run(["docker-compose-update-all"]) -- cgit v1.2.3