MCPcopy Create free account
hub / github.com/conda/constructor / create

Function create

constructor/docker_build.py:149–189  ·  view source on GitHub ↗

Build a Docker output from a previously built ``.sh`` installer. The ``.sh`` installer is built and must exist at ``info["_outpath"]`` before this function is called. Parameters ---------- info: dict Constructor installer info dict. verbose: bool, optional I

(info: dict, verbose: bool = False)

Source from the content-addressed store, hash-verified

147
148
149def create(info: dict, verbose: bool = False) -> None:
150 """Build a Docker output from a previously built ``.sh`` installer.
151
152 The ``.sh`` installer is built and must exist at ``info["_outpath"]``
153 before this function is called.
154
155 Parameters
156 ----------
157 info: dict
158 Constructor installer info dict.
159 verbose: bool, optional
160 If ``True``, enables verbose logging.
161 Defaults to ``False``.
162
163 """
164 with tempfile.TemporaryDirectory() as temp_dir:
165 docker_tmp_dir = Path(temp_dir)
166
167 installer_path = Path(info["_outpath"])
168 if not installer_path.exists():
169 raise RuntimeError(f"Expected .sh installer not found: {installer_path}")
170 shutil.copy(installer_path, docker_tmp_dir / installer_path.name)
171 logger.info("Copied installer to build directory.")
172
173 generate_dockerfile(info, docker_tmp_dir)
174
175 if info.get("docker_image_format"):
176 tarball = build_image(info, docker_tmp_dir)
177 shutil.copy(tarball, Path(info["_output_dir"]) / tarball.name)
178 else:
179 output_dir = Path(info["_output_dir"]) / installer_path.stem
180 output_dir.mkdir(parents=True, exist_ok=True)
181 shutil.copy(docker_tmp_dir / "Dockerfile", output_dir / "Dockerfile")
182 shutil.copy(
183 docker_tmp_dir / Path(info["_outpath"]).name,
184 output_dir / Path(info["_outpath"]).name,
185 )
186
187 logger.info("Docker output complete. Docker directory: '%s'", info["_output_dir"])
188
189 installer_path.unlink(missing_ok=True)

Callers

nothing calls this directly

Calls 3

generate_dockerfileFunction · 0.85
build_imageFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected