Skip to content

Commit 2d1fccf

Browse files
fix: updated docker image path to be included in graph config
1 parent f8c4bfb commit 2d1fccf

File tree

3 files changed

+8
-25
lines changed

3 files changed

+8
-25
lines changed

src/taskgraph/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
# The trust-domain for this graph.
2727
# (See https://firefox-source-docs.mozilla.org/taskcluster/taskcluster/taskgraph.html#taskgraph-trust-domain) # noqa
2828
Required("trust-domain"): str,
29+
Optional(
30+
"docker-image-path",
31+
description="Paths to the docker image directories relative to the root directory.",
32+
): [str],
2933
Required("task-priority"): optionally_keyed_by(
3034
"project",
3135
"level",

src/taskgraph/transforms/task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ def build_docker_worker_payload(config, task, task_def):
561561
image = worker["docker-image"]
562562
if isinstance(image, dict):
563563
if "in-tree" in image:
564-
name = image["in-tree"]
564+
file_path = config.graph_config["docker-image-path"]
565565
docker_image_task = "docker-image-" + image["in-tree"]
566566
assert "docker-image" not in task.get("dependencies", ()), (
567567
"docker-image key in dependencies object is reserved"
@@ -575,7 +575,7 @@ def build_docker_worker_payload(config, task, task_def):
575575
}
576576

577577
# Find VOLUME in Dockerfile.
578-
volumes = dockerutil.parse_volumes(name)
578+
volumes = dockerutil.parse_volumes(file_path)
579579
for v in sorted(volumes):
580580
if v in worker["volumes"]:
581581
raise Exception(

src/taskgraph/util/docker.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
IMAGE_DIR = os.path.join(".", "taskcluster", "docker")
1616

17-
from .yaml import load_yaml
18-
1917

2018
def docker_image(name: str, by_tag: bool = False) -> Optional[str]:
2119
"""
@@ -206,30 +204,11 @@ def stream_context_tar(topsrcdir, context_dir, out_file, args=None):
206204

207205

208206
@functools.lru_cache(maxsize=None)
209-
def image_paths():
210-
"""Return a map of image name to paths containing their Dockerfile."""
211-
config = load_yaml("taskcluster", "kinds", "docker-image", "kind.yml")
212-
return {
213-
k: os.path.join(IMAGE_DIR, v.get("definition", k))
214-
for k, v in config["tasks"].items()
215-
}
216-
217-
218-
def image_path(name):
219-
paths = image_paths()
220-
if name in paths:
221-
return paths[name]
222-
return os.path.join(IMAGE_DIR, name)
223-
224-
225-
@functools.lru_cache(maxsize=None)
226-
def parse_volumes(image):
207+
def parse_volumes(file_path):
227208
"""Parse VOLUME entries from a Dockerfile for an image."""
228209
volumes = set()
229210

230-
path = image_path(image)
231-
232-
with open(os.path.join(path, "Dockerfile"), "rb") as fh:
211+
with open(file_path, "rb") as fh:
233212
for line in fh:
234213
line = line.strip()
235214
# We assume VOLUME definitions don't use %ARGS.

0 commit comments

Comments
 (0)