Skip to content

Commit d055733

Browse files
authored
Merge pull request #809 from b-ehlers/threads
Docker build: speed up getting information of images
2 parents 5558bd3 + 6cf40f9 commit d055733

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/bin/docker_build

+28
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Docker repository to use for name-only targets.
5555
import os
5656
import sys
5757
import argparse
58+
import concurrent.futures
5859
import datetime
5960
import json
6061
import re
@@ -418,6 +419,32 @@ def fill_login_table():
418419
return login_table
419420

420421

422+
def get_images_info(all_flag, forced_images):
423+
""" get information of all images and base images """
424+
image_list = set()
425+
for image in images:
426+
if "/" in image["image"]: # full image name
427+
base_repos = [None]
428+
else: # name-only image name
429+
base_repos = docker_repositories
430+
if xor(all_flag, image["image"] in forced_images or \
431+
image["base"] in forced_images):
432+
continue # no need to get info of forced images
433+
for repo in base_repos:
434+
full_name = full_image_name(image["image"], repo)
435+
base_name, _ = expand_base_image(image["base"], full_name)
436+
image_list.add(base_name)
437+
image_list.add(full_name)
438+
for image in image_info:
439+
image_list.discard(image) # image info already available
440+
441+
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:
442+
futures = {executor.submit(get_time_layers, image): image
443+
for image in image_list}
444+
for future in concurrent.futures.as_completed(futures):
445+
image_info[futures[future]] = future.result()
446+
447+
421448
def rebuild_images(dry_run, all_flag, forced_images):
422449
""" rebuild images """
423450
for image in images:
@@ -489,4 +516,5 @@ for img in images:
489516
"Environment variable DOCKER_REPOSITORY is not defined")
490517

491518
# rebuild images
519+
get_images_info(args.all, args.image)
492520
rebuild_images(args.dry_run, args.all, args.image)

0 commit comments

Comments
 (0)