diff --git a/publish_images.py b/publish_images.py new file mode 100755 index 0000000000000000000000000000000000000000..c32156b51c653ef2ce97c1f78c601d41520b46dc --- /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()