MCPcopy Create free account
hub / github.com/ceph/ceph / build

Method build

src/script/cpatch.py:450–481  ·  view source on GitHub ↗

Build the container image.

(self)

Source from the content-addressed store, hash-verified

448 self._jobs.append((component, job))
449
450 def build(self):
451 """Build the container image."""
452 dlines = [f"FROM {self._ctx.base_image}"]
453 for cmd in self._ctx.run_before_commands:
454 dlines.append(f'RUN {cmd}')
455 jcount = len(self._jobs)
456 for idx, (component, job) in enumerate(self._jobs):
457 num = idx + 1
458 log.info(f"Executing job {num}/{jcount} for {component}")
459 dresult = job(component)
460 dlines.extend(dresult)
461
462 if os.path.isdir(self._workdir / "tmp_bin"):
463 # For every binary file that was copied to the tmp_bin directory by the jobs above, search for the existing file in the container and replace it.
464 dlines.append("ADD tmp_bin /tmpbin")
465 dlines.append("RUN for i in tmpbin/*; do find /usr/bin /usr/sbin -name $(basename $i) -exec mv -f $i '{}' \;; echo $(basename $i); done && rm -rf tmpbin")
466
467 if os.path.isdir(self._workdir / "tmp_lib"):
468 # For every library file that was copied to the tmp_lib directory by the jobs above, search for the existing file in the container and replace it.
469 dlines.append("ADD tmp_lib /tmplib")
470 dlines.append("RUN for i in tmplib/*; do find /usr/lib64 -name $(basename $i) -exec mv -f $i '{}' \;; echo $(basename $i); done && rm -rf tmplib")
471
472 if os.path.isdir(self._workdir / "tmp_bin"):
473 # by default locally built binaries assume /usr/local
474 dlines.append("RUN rm -rf /usr/local/lib64 && ln -sf /usr/lib64 /usr/local && ln -sf /usr/share/ceph /usr/local/share")
475 # locally built binaries assume libceph-common.so.2 is in /usr/lib64 - create link to library that was just copied
476 dlines.append("RUN ln -sf /usr/lib64/ceph/libceph-common.so.2 /usr/lib64/libceph-common.so.2")
477
478 with open(self._workdir / "Dockerfile", "w") as fout:
479 for line in dlines:
480 print(line, file=fout)
481 self._container_build()
482
483 def _container_build(self):
484 log.info("Building container image")

Callers 1

mainFunction · 0.45

Calls 5

_container_buildMethod · 0.95
printFunction · 0.85
extendMethod · 0.80
appendMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected