def parse_prod_digests() -> Dict[str, str]: image_urls_to_prod_digests = {} with open(utils.PROD_DIGESTS_PATH, "r") as f: for line in f: image_url, digest = line.strip().split("@") image_urls_to_prod_digests[image_url] = digest return image_urls_to_prod_digests if __name__ == '__main__': args = parse_arguments() # Ensure the user has the correct authorization to push to GCR. utils.check_gcloud_auth(dry_run=args.dry_run) images_to_process = get_ordered_images_to_process(args.images) print( f'Also processing dependent images. Will process: {images_to_process}') dependencies = get_dependencies(images_to_process) print(f'Pulling image dependencies: {dependencies}') image_urls_to_prod_digests = parse_prod_digests() for dependency in dependencies: dependency_url = posixpath.join(IREE_GCR_URL, dependency) # If `dependency` is a new image then it may not have a prod digest yet. if dependency_url in image_urls_to_prod_digests: digest = image_urls_to_prod_digests[dependency_url] dependency_with_digest = f'{dependency_url}@{digest}' utils.run_command(["docker", "pull", dependency_with_digest],
# limitations under the License. """Uses prod_digests.txt to update GCR's :prod tags. Usage: Pull all images that should have :prod tags, tag the with :prod and push them to GCR. This will make sure that you are at upstream head on the main branch before pushing: python3 build_tools/docker/manage_prod.py """ import os import utils if __name__ == "__main__": # Ensure the user has the correct authorization if they try to push to GCR. utils.check_gcloud_auth() # Only allow the :prod tag to be pushed from the version of # `prod_digests.txt` at upstream HEAD on the main branch. utils.run_command([os.path.normpath("scripts/git/git_update.sh"), "main"]) with open(utils.PROD_DIGESTS_PATH, "r") as f: images_with_digests = [line.strip() for line in f.readlines()] for image_with_digest in images_with_digests: image_url, _ = image_with_digest.split("@") prod_image_url = f"{image_url}:prod" utils.run_command(["docker", "pull", image_with_digest]) utils.run_command(["docker", "tag", image_with_digest, prod_image_url]) utils.run_command(["docker", "push", prod_image_url])