MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / _build_locked

Method _build_locked

misc/python/materialize/mzbuild.py:1036–1133  ·  view source on GitHub ↗
(
        self, prep: dict[type[PreImage], Any], push: bool = False
    )

Source from the content-addressed store, hash-verified

1034 fcntl.flock(lock_file, fcntl.LOCK_UN)
1035
1036 def _build_locked(
1037 self, prep: dict[type[PreImage], Any], push: bool = False
1038 ) -> None:
1039 ui.section(f"Building {self.spec()}")
1040 spawn.runv(["git", "clean", "-ffdX", self.image.path])
1041
1042 for pre_image in self.image.pre_images:
1043 pre_image.run(prep[type(pre_image)])
1044 build_args = {
1045 **self.image.build_args,
1046 "BUILD_PROFILE": self.image.rd.profile.name,
1047 "ARCH_GCC": str(self.image.rd.arch),
1048 "ARCH_GO": self.image.rd.arch.go_str(),
1049 "CI_SANITIZER": str(self.image.rd.sanitizer),
1050 }
1051 f = self.write_dockerfile()
1052
1053 try:
1054 spawn.capture(["docker", "buildx", "version"])
1055 except subprocess.CalledProcessError:
1056 if push:
1057 print(
1058 "docker buildx not found, required to push images. Installation: https://github.com/docker/buildx?tab=readme-ov-file#installing"
1059 )
1060 raise
1061 print(
1062 "docker buildx not found, you can install it to build faster. Installation: https://github.com/docker/buildx?tab=readme-ov-file#installing"
1063 )
1064 print("Falling back to docker build")
1065 cmd: Sequence[str] = [
1066 "docker",
1067 "build",
1068 "-f",
1069 "-",
1070 *(f"--build-arg={k}={v}" for k, v in build_args.items()),
1071 "-t",
1072 self.spec(),
1073 f"--platform=linux/{self.image.rd.arch.go_str()}",
1074 str(self.image.path),
1075 ]
1076 else:
1077 docker_tag = f"docker.io/{self.spec()}"
1078 ghcr_tag = f"ghcr.io/materializeinc/{self.spec()}"
1079 cmd: Sequence[str] = [
1080 "docker",
1081 "buildx",
1082 "build",
1083 "--progress=plain", # less noisy
1084 "-f",
1085 "-",
1086 *(f"--build-arg={k}={v}" for k, v in build_args.items()),
1087 "-t",
1088 docker_tag,
1089 "-t",
1090 ghcr_tag,
1091 f"--platform=linux/{self.image.rd.arch.go_str()}",
1092 str(self.image.path),
1093 "--load",

Callers 1

buildMethod · 0.95

Calls 9

specMethod · 0.95
write_dockerfileMethod · 0.95
go_strMethod · 0.80
captureMethod · 0.80
runMethod · 0.45
itemsMethod · 0.45
encodeMethod · 0.45
waitMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected