From e6242c9bbe2c8ae36e7787f49e52fb1707c9d80a Mon Sep 17 00:00:00 2001 From: Tamas Gal <tgal@km3net.de> Date: Tue, 13 Nov 2018 16:39:59 +0100 Subject: [PATCH] Add publisher script --- publish_images.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 publish_images.py diff --git a/publish_images.py b/publish_images.py new file mode 100755 index 0000000..c32156b --- /dev/null +++ b/publish_images.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +from glob import glob +import subprocess as sp +import sys +import time + +REGISTRY_URL = 'docker.km3net.de' + + +def main(): + dockerfiles = glob('base/*:*') + n_files = len(dockerfiles) + print("Processing {} dockerfiles...".format(n_files)) + for idx, fname in enumerate(dockerfiles): + progress = "({}/{})".format(idx + 1, n_files) + + print('-' * 79) + print("{} Building '{}'".format(progress, fname)) + build_cmd = ("docker build --pull -t {0}/{1} -f {1} . ".format( + REGISTRY_URL, fname)) + child = sp.Popen( + build_cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr) + child.communicate() + + print("{} Publishing '{}'".format(progress, fname)) + push_cmd = ("docker push {0}/{1}".format(REGISTRY_URL, fname)) + child = sp.Popen( + push_cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr) + child.communicate() + +if __name__ == '__main__': + main() -- GitLab