diff --git a/scripts/build/build.py b/scripts/build/build.py index 317744d..bec7364 100644 --- a/scripts/build/build.py +++ b/scripts/build/build.py @@ -26,7 +26,8 @@ parser.add_argument("-b","--backfill",default=3,help="Number of latest upstream git tags to build images for [default: 3]") parser.add_argument("-r","--registry",help="Where to push images to, / will be appended") parser.add_argument("-p", "--platform",action="append",default=["linux/amd64"],help="Platform to build for. Repeat to build a multi-platform image [default: linux/amd64]") -parser.add_argument("--push",action='store_true',default=False,help="Push image to registry [default: False]") +parser.add_argument("--push",action="store_true",default=False,help="Push image to registry [default: False]") +parser.add_argument("--dry-run",action="store_true",default=False,help="Do not actually build images [default: False]") args = parser.parse_args() #--- @@ -115,24 +116,27 @@ docker.buildx.imagetools.inspect(tags[0]) logger.info("Image " + tags[0] + " exists, nothing to to.") except: - # Build if image does not exist - logger.info("Building " + tags[0]) - stream = ( - docker.buildx.build( - # Build specific - context_path = context, - build_args = {"VERSION": version}, - platforms = args.platform, - target = target, - push = args.push, - tags = tags, - labels = { - **build["labels"], - "org.prind.image.version": version - }, - stream_logs = True + if args.dry_run: + logger.debug("[dry-run] Would build " + tags[0]) + else: + # Build if image does not exist + logger.info("Building " + tags[0]) + stream = ( + docker.buildx.build( + # Build specific + context_path = context, + build_args = {"VERSION": version}, + platforms = args.platform, + target = target, + push = args.push, + tags = tags, + labels = { + **build["labels"], + "org.prind.image.version": version + }, + stream_logs = True + ) ) - ) - for line in stream: - logger.info("BUILD: " + line.strip()) \ No newline at end of file + for line in stream: + logger.info("BUILD: " + line.strip()) \ No newline at end of file