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

Function build_container

src/script/build-with-container.py:721–757  ·  view source on GitHub ↗

Generate a build environment container image.

(ctx)

Source from the content-addressed store, hash-verified

719
720@Builder.set(Steps.BUILD_CONTAINER)
721def build_container(ctx):
722 """Generate a build environment container image."""
723 ctx.build.wants(Steps.DNF_CACHE, ctx)
724 cmd = [
725 ctx.container_engine,
726 "build",
727 "--pull",
728 "-t",
729 ctx.image_name,
730 f"--label=io.ceph.build-with-container.src={_hash_sources()}",
731 f"--label=io.ceph.build-with-container.image-variant={ctx.variant()}",
732 f"--build-arg=CEPH_BASE_BRANCH={ctx.base_branch()}",
733 ]
734 if ctx.cli.distro:
735 cmd.append(f"--build-arg=DISTRO={ctx.from_image}")
736 if ctx.dnf_cache_dir and "docker" in ctx.container_engine:
737 log.warning(
738 "The --volume option is not supported by docker build/buildx. Skipping dnf cache dir mounts"
739 )
740 elif ctx.dnf_cache_dir:
741 cmd += [
742 f"--volume={ctx.dnf_cache_dir}/lib:/var/lib/dnf:Z",
743 f"--volume={ctx.dnf_cache_dir}:/var/cache/dnf:Z",
744 "--build-arg=CLEAN_DNF=no",
745 ]
746 if ctx.packages_build():
747 cmd.append("--build-arg=FOR_MAKE_CHECK=false")
748 crimson_build = ctx.crimson_build()
749 if crimson_build is not None:
750 # the WITH_CRIMSON var is false only when empty (in install-deps)
751 with_crimson = '1' if crimson_build else ''
752 cmd.append(f"--build-arg=WITH_CRIMSON={with_crimson}")
753 if ctx.cli.build_args:
754 cmd.extend([f"--build-arg={v}" for v in ctx.cli.build_args])
755 cmd += ["-f", ctx.cli.containerfile, ctx.cli.containerdir]
756 with ctx.user_command():
757 _run(cmd, check=True, ctx=ctx)
758
759
760def _check_cached_image(ctx):

Callers

nothing calls this directly

Calls 11

_hash_sourcesFunction · 0.85
wantsMethod · 0.80
variantMethod · 0.80
base_branchMethod · 0.80
packages_buildMethod · 0.80
crimson_buildMethod · 0.80
extendMethod · 0.80
user_commandMethod · 0.80
_runFunction · 0.70
appendMethod · 0.45
warningMethod · 0.45

Tested by

no test coverage detected