mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1290531 - Add mach taskcluster-build-image command; r=dustin
Docker image building will soon need to use Python in order to produce the image build context archive. As the first step towards this, we introduce a Python function that calls out to build.sh. We also implement a mach command that calls it so we can test the functionality. I'm not keen about introducing a new mach command. I'd prefer to have a sub-command instead. I'm not sure what all uses `mach taskcluster-load-image`. Perhaps we could make a `taskcluster` top-level command. Or perhaps we could fold these image commands into `mach taskgraph`? Either way, the mach side of this isn't terribly important to the commit series: most of the code will live inside a Python module outside of mach. MozReview-Commit-ID: AI8p6H4psNh --HG-- extra : rebase_source : a3a18cbeb05152ab65f2bf152fd2517bbcd8981e
This commit is contained in:
parent
7d2c453f6e
commit
d880926e5a
@ -228,7 +228,7 @@ class MachCommands(MachCommandBase):
|
||||
|
||||
|
||||
@CommandProvider
|
||||
class LoadImage(object):
|
||||
class TaskClusterImagesProvider(object):
|
||||
@Command('taskcluster-load-image', category="ci",
|
||||
description="Load a pre-built Docker image")
|
||||
@CommandArgument('--task-id',
|
||||
@ -253,3 +253,16 @@ class LoadImage(object):
|
||||
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)
|
||||
|
@ -15,6 +15,7 @@ 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/{}'
|
||||
|
||||
@ -61,3 +62,14 @@ def load_image_by_task_id(task_id):
|
||||
|
||||
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')
|
||||
|
Loading…
Reference in New Issue
Block a user