|
26 | 26 | zstd = e |
27 | 27 |
|
28 | 28 | from taskgraph.config import GraphConfig |
29 | | -from taskgraph.transforms.docker_image import IMAGE_BUILDER_IMAGE |
| 29 | +from taskgraph.transforms import docker_image |
30 | 30 | from taskgraph.util import docker, json |
31 | 31 | from taskgraph.util.taskcluster import ( |
32 | 32 | find_task_id, |
@@ -162,22 +162,31 @@ def build_image( |
162 | 162 | if not os.path.isdir(image_dir): |
163 | 163 | raise Exception(f"image directory does not exist: {image_dir}") |
164 | 164 |
|
165 | | - label = f"docker-image-{name}" |
166 | | - image_tasks = load_tasks_for_kind( |
167 | | - {"do_not_optimize": [label]}, |
168 | | - "docker-image", |
169 | | - graph_attr="morphed_task_graph", |
170 | | - write_artifacts=True, |
171 | | - ) |
172 | | - |
173 | | - image_context = Path(f"docker-contexts/{name}.tar.gz").resolve() |
174 | | - if context_file: |
175 | | - shutil.move(image_context, context_file) |
176 | | - return "" |
177 | | - |
178 | 165 | with tempfile.TemporaryDirectory() as temp_dir: |
179 | 166 | temp_dir = Path(temp_dir) |
180 | | - output_dir = temp_dir / "artifacts" |
| 167 | + |
| 168 | + # Ensure the docker-image transforms save the docker-contexts to our |
| 169 | + # temp_dir |
| 170 | + label = f"docker-image-{name}" |
| 171 | + contexts_dir = temp_dir / "docker-contexts" |
| 172 | + old_contexts_dir = docker_image.CONTEXTS_DIR |
| 173 | + try: |
| 174 | + docker_image.CONTEXTS_DIR = str(contexts_dir) |
| 175 | + image_tasks = load_tasks_for_kind( |
| 176 | + {"do_not_optimize": [label]}, |
| 177 | + "docker-image", |
| 178 | + graph_attr="morphed_task_graph", |
| 179 | + write_artifacts=True, |
| 180 | + ) |
| 181 | + finally: |
| 182 | + docker_image.CONTEXTS_DIR = old_contexts_dir |
| 183 | + |
| 184 | + image_context = contexts_dir.joinpath(f"{name}.tar.gz").resolve() |
| 185 | + if context_file: |
| 186 | + shutil.move(image_context, context_file) |
| 187 | + return "" |
| 188 | + |
| 189 | + output_dir = temp_dir / "out" |
181 | 190 | output_dir.mkdir() |
182 | 191 | volumes = { |
183 | 192 | # TODO write artifacts to tmpdir |
@@ -208,7 +217,7 @@ def build_image( |
208 | 217 | load_task( |
209 | 218 | graph_config, |
210 | 219 | task_def, |
211 | | - custom_image=IMAGE_BUILDER_IMAGE, |
| 220 | + custom_image=docker_image.IMAGE_BUILDER_IMAGE, |
212 | 221 | interactive=False, |
213 | 222 | volumes=volumes, |
214 | 223 | ) |
|
0 commit comments