@@ -45,13 +45,15 @@ def build_container_image(labels, buildDir, containerfile, fromimage, cacheTTL,
4545 runcmd (cmd )
4646
4747
48- def push_container_image (repo , tag ):
48+ def push_container_image (repo , tag , digestfile ):
4949 '''
5050 Push image to registry
5151 @param repo str registry repository
5252 @param tag str image tag
5353 '''
5454 cmd = ["podman" , "push" , f"{ repo } :{ tag } " ]
55+ if digestfile is not None :
56+ cmd .extend (["--digestfile" , digestfile ])
5557 # Long running command. Send output to stdout for logging
5658 runcmd (cmd )
5759 # Quay seems to take some time to publish images in some occasions.
@@ -132,6 +134,8 @@ def main():
132134 # Check for requisite env vars
133135 if os .environ .get ('CONTAINER_HOST' ) is None or os .environ .get ('CONTAINER_SSHKEY' ) is None :
134136 sys .exit ('You must have CONTAINER_HOST and CONTAINER_SSHKEY environment variables setup' )
137+ if args .write_digest_to_file is not None and not args .push_to_registry :
138+ sys .exit ('argument --write-digest-to-file can only be used with --push-to-registry' )
135139
136140 # Podman supports building from a specific commit
137141 # (https://github.com/containers/buildah/issues/4148), but the way
@@ -193,7 +197,7 @@ def main():
193197 # Push to the registry if needed, else save the image to a file
194198 if args .push_to_registry :
195199 logging .info ("Pushing to remote registry" )
196- push_container_image (args .repo , args .tag )
200+ push_container_image (args .repo , args .tag , args . write_digest_to_file )
197201 else :
198202 logging .info ("Archiving build container image from remote" )
199203 pull_oci_archive_from_remote (args .repo , args .tag , args .write_to_file )
@@ -265,6 +269,9 @@ Examples:
265269 parser .add_argument (
266270 '--tag' , required = False ,
267271 help = 'Force image tag. The default is arch-commit' )
272+ parser .add_argument (
273+ '--write-digest-to-file' , required = False ,
274+ help = 'Write digest of pushed image to named file' )
268275 group = parser .add_mutually_exclusive_group (required = True )
269276 group .add_argument (
270277 '--push-to-registry' , required = False , action = 'store_true' ,
0 commit comments