author | Gregory Szorc <gps@mozilla.com> |
Fri, 29 Jul 2016 12:45:25 -0700 | |
changeset 307528 | b6eff3784cf2bc9583c5c8476816e4ade138fb46 |
parent 307527 | d645b6c90e9dd518524629edce8b9efbafcba810 |
child 307529 | 4509921b0cfd298f27e5164d8ee6361fb2ae2eb2 |
push id | 30969 |
push user | gszorc@mozilla.com |
push date | Mon, 01 Aug 2016 18:28:55 +0000 |
treeherder | autoland@ed95bb78b383 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | dustin |
bugs | 1290531 |
milestone | 50.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
taskcluster/mach_commands.py | file | annotate | diff | comparison | revisions | |
taskcluster/taskgraph/docker.py | file | annotate | diff | comparison | revisions |
--- a/taskcluster/mach_commands.py +++ b/taskcluster/mach_commands.py @@ -223,17 +223,17 @@ class MachCommands(MachCommandBase): print(label) def show_taskgraph_json(self, taskgraph): print(json.dumps(taskgraph.to_json(), sort_keys=True, indent=2, separators=(',', ': '))) @CommandProvider -class LoadImage(object): +class TaskClusterImagesProvider(object): @Command('taskcluster-load-image', category="ci", description="Load a pre-built Docker image") @CommandArgument('--task-id', help="Load the image at public/image.tar in this task," "rather than searching the index") @CommandArgument('image_name', nargs='?', help="Load the image of this name based on the current" "contents of the tree (as built for mozilla-central" @@ -248,8 +248,21 @@ class LoadImage(object): ok = load_image_by_task_id(task_id) else: ok = load_image_by_name(image_name) if not ok: sys.exit(1) except Exception: traceback.print_exc() sys.exit(1) + + @Command('taskcluster-build-image', category='ci', + description='Build a Docker image') + @CommandArgument('image_name', + help='Name of the image to build') + def build_image(self, image_name): + from taskgraph.docker import build_image + + try: + build_image(image_name) + except Exception: + traceback.print_exc() + sys.exit(1)
--- a/taskcluster/taskgraph/docker.py +++ b/taskcluster/taskgraph/docker.py @@ -10,16 +10,17 @@ import json import os import subprocess import tarfile import urllib2 from taskgraph.util import docker GECKO = os.path.realpath(os.path.join(__file__, '..', '..', '..')) +IMAGE_DIR = os.path.join(GECKO, 'testing', 'docker') INDEX_URL = 'https://index.taskcluster.net/v1/task/docker.images.v1.{}.{}.hash.{}' ARTIFACT_URL = 'https://queue.taskcluster.net/v1/task/{}/artifacts/{}' def load_image_by_name(image_name): context_path = os.path.join(GECKO, 'testing', 'docker', image_name) context_hash = docker.generate_context_hash(GECKO, context_path, image_name) @@ -56,8 +57,19 @@ def load_image_by_task_id(task_id): print("*** problem and running `docker load < {}`.".format(filename)) raise print("Deleting temporary file") os.unlink(filename) print("The requested docker image is now available as", name) print("Try: docker run -ti --rm {} bash".format(name)) + + +def build_image(name): + """Build a Docker image of specified name. + + Output from image building process will be printed to stdout. + """ + args = [os.path.join(IMAGE_DIR, 'build.sh'), name] + res = subprocess.call(args, cwd=IMAGE_DIR) + if res: + raise Exception('error building image')