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

Function generate_dockerfile

constructor/docker_build.py:50–85  ·  view source on GitHub ↗

Render the Dockerfile template and write it to the Docker build directory. Parameters ---------- info: dict Constructor installer info dict. docker_dir: Path Path to the Docker build directory. Returns ------- Path Path to the generated Dock

(info: dict, docker_dir: Path)

Source from the content-addressed store, hash-verified

48
49
50def generate_dockerfile(info: dict, docker_dir: Path) -> Path:
51 """
52 Render the Dockerfile template and write it to the Docker build directory.
53
54 Parameters
55 ----------
56 info: dict
57 Constructor installer info dict.
58 docker_dir: Path
59 Path to the Docker build directory.
60
61 Returns
62 -------
63 Path
64 Path to the generated Dockerfile.
65 """
66
67 rendered_dockerfile = Template(TEMPLATE_PATH.read_text()).render(
68 constructor_version=__version__,
69 base_image=info.get("docker_base_image"),
70 default_prefix=info.get("default_prefix", f"/opt/{info['name'].lower()}"),
71 installer_filename=Path(info["_outpath"]).name,
72 conda_exe_name=format_conda_exe_name(info["_conda_exe"]),
73 name=info["name"],
74 version=info["version"],
75 labels=info.get("docker_labels", {}),
76 initialize_conda=info.get("initialize_conda"),
77 register_envs=info.get("register_envs"),
78 keep_pkgs=info.get("keep_pkgs"),
79 init_run_block=_build_init_run_block(info),
80 )
81
82 logger.info("Writing Dockerfile...")
83 dockerfile_path = docker_dir / "Dockerfile"
84 dockerfile_path.write_text(rendered_dockerfile)
85 return dockerfile_path
86
87
88def build_image(info: dict, docker_dir: Path) -> Path:

Callers 1

createFunction · 0.85

Calls 4

format_conda_exe_nameFunction · 0.85
_build_init_run_blockFunction · 0.85
getMethod · 0.80
read_textMethod · 0.45

Tested by

no test coverage detected