Skip to content

Commit

Permalink
build: add dry run mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuf committed Feb 26, 2024
1 parent 210c6b9 commit 189d954
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions scripts/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, /<app> 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()

#---
Expand Down Expand Up @@ -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())
for line in stream:
logger.info("BUILD: " + line.strip())

0 comments on commit 189d954

Please sign in to comment.