From 71b0e296f725baf501b4af81cf82dd1aad428003 Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Thu, 14 Sep 2023 22:17:25 -0500 Subject: Provide an option to build multiple compose files within a single call --- README.md | 14 +++++++------- rbuild.py | 10 ++++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index cb75387..c03175b 100644 --- a/README.md +++ b/README.md @@ -85,21 +85,21 @@ WantedBy=timers.target ## Usage ``` -usage: rbuild.py [-h] [--build-period BUILD_PERIOD] [--up-timeout-period UP_TIMEOUT_PERIOD] [--force-rebuild] [--remove-images] filename +usage: rbuild.py [-h] [--build-period BUILD_PERIOD] [--up-timeout-period UP_TIMEOUT_PERIOD] [--force-rebuild] [--remove-images] filename [filename ...] -Automatically rebuild a series of containers using Docker Compose. +Automatically rebuild a series of containers with docker compose. positional arguments: filename The docker-compose file to use. options: - -h, --help Show this help message and exit. + -h, --help show this help message and exit --build-period BUILD_PERIOD - Rebuild period in seconds. + Time images are allowed to live (in seconds.) --up-timeout-period UP_TIMEOUT_PERIOD - Timeout period for bringing up containers in seconds. - --force-rebuild Force a rebuild of all containers. - --remove-images Remove all existing images. + Up timeout period in seconds. + --force-rebuild Force all containers to be rebuilt + --remove-images Remove all images ``` ## License diff --git a/rbuild.py b/rbuild.py index c39e33e..6ba7a79 100644 --- a/rbuild.py +++ b/rbuild.py @@ -164,7 +164,7 @@ if __name__ == '__main__': parser = argparse.ArgumentParser(description='Automatically rebuild a series of containers with docker compose.') - parser.add_argument('filename', type=str, help='The docker-compose file to use.') + parser.add_argument('filename', type=str, nargs='+', help='The docker-compose file to use.') parser.add_argument('--build-period', type=int, default=BUILD_TTL, help='Time images are allowed to live (in seconds.)') parser.add_argument('--up-timeout-period', type=int, default=UP_TIMEOUT_PERIOD, help='Up timeout period in seconds.') @@ -185,8 +185,10 @@ if __name__ == '__main__': if args.remove_images and args.force_rebuild: die("Error: --remove-images cannot be used with --force-rebuild") - if args.remove_images: - remove_main(args.filename) + for filename in args.filename: - build_main(args.filename, force_rebuild=args.force_rebuild) + if args.remove_images: + remove_main(filename) + + build_main(filename, force_rebuild=args.force_rebuild) -- cgit v1.2.3