Skip to content

Commit 1ae4655

Browse files
committed
mzbuild: push docker images in parallel
This should speed up builds substantially.
1 parent d7c3592 commit 1ae4655

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

misc/python/materialize/mzbuild.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import json
2323
import os
2424
import re
25+
import shlex
2526
import shutil
2627
import stat
2728
import subprocess
@@ -833,10 +834,25 @@ def ensure(self) -> None:
833834
"""
834835
deps_to_build = [dep for dep in self if not dep.is_published_if_necessary()]
835836
self._prepare_batch(deps_to_build)
837+
838+
images_to_push = []
836839
for dep in deps_to_build:
837840
dep.build()
838841
if dep.publish:
839-
spawn.runv(["docker", "push", dep.spec()])
842+
images_to_push.append(dep.spec())
843+
844+
pushes: list[subprocess.Popen] = []
845+
for image in images_to_push:
846+
push = subprocess.Popen(
847+
f"docker push {shlex.quote(image)} | cat",
848+
shell=True,
849+
)
850+
pushes.append(push)
851+
852+
for push in pushes:
853+
returncode = push.wait()
854+
if returncode:
855+
raise subprocess.CalledProcessError(returncode, push.args)
840856

841857
def __iter__(self) -> Iterator[ResolvedImage]:
842858
return iter(self._dependencies.values())

0 commit comments

Comments
 (0)