File tree 1 file changed +22
-1
lines changed 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 22
22
import json
23
23
import os
24
24
import re
25
+ import shlex
25
26
import shutil
26
27
import stat
27
28
import subprocess
@@ -836,10 +837,30 @@ def ensure(self) -> None:
836
837
"""
837
838
deps_to_build = [dep for dep in self if not dep .is_published_if_necessary ()]
838
839
self ._prepare_batch (deps_to_build )
840
+
841
+ images_to_push = []
839
842
for dep in deps_to_build :
840
843
dep .build ()
841
844
if dep .publish :
842
- spawn .runv (["docker" , "push" , dep .spec ()])
845
+ images_to_push .append (dep .spec ())
846
+
847
+ # Push all Docker images in parallel to minimize build time.
848
+ pushes : list [subprocess .Popen ] = []
849
+ for image in images_to_push :
850
+ # Piping through `cat` disables terminal control codes, and so the
851
+ # interleaved progress output from multiple pushes is less hectic.
852
+ # We don't use `docker push --quiet`, as that disables progress
853
+ # output entirely.
854
+ push = subprocess .Popen (
855
+ f"docker push { shlex .quote (image )} | cat" ,
856
+ shell = True ,
857
+ )
858
+ pushes .append (push )
859
+
860
+ for push in pushes :
861
+ returncode = push .wait ()
862
+ if returncode :
863
+ raise subprocess .CalledProcessError (returncode , push .args )
843
864
844
865
def __iter__ (self ) -> Iterator [ResolvedImage ]:
845
866
return iter (self ._dependencies .values ())
You can’t perform that action at this time.
0 commit comments