build-images: Add support for docker base images

DIB recently got some new capabilities to help build
docker images. This patch updates build-images so
that it supports:

 -skip_base: to skip the 'base' element if you wish to do so
 -docker_target: the name of the docker target to create
 - the type option is properly passed into DIB so that it
   doesn't always default to qcow.

Using these new build-images options it is should be possible
to create .yaml files that help define how to build docker
images.

Change-Id: I9b9464c88bb6ce2914cd499ba4fe207ce355bf70
Depends-On: Ib60db3b717d33d4cf3181d70fe0ffbfa86fd5d02
This commit is contained in:
Dan Prince 2015-07-08 22:11:41 -04:00
parent aec0a988a9
commit d37cd2207c
1 changed files with 12 additions and 2 deletions

View File

@ -96,6 +96,8 @@ def main(argv=sys.argv):
for image in disk_images:
arch = image.get('arch', 'amd64')
img_type = image.get('type', 'qcow2')
skip_base = image.get('skip_base', 'false')
docker_target = image.get('docker_target')
imagename = image.get('imagename')
logger.info('imagename: %s' % imagename)
image_path = '%s/%s.%s' % (opts.output_directory, imagename, img_type)
@ -108,17 +110,25 @@ def main(argv=sys.argv):
elements = image.get('elements', [])
options = image.get('options', [])
packages = image.get('packages', [])
cmd = ['disk-image-create', '-a', arch, '-o', image_path]
cmd = ['disk-image-create', '-a', arch, '-o', image_path, '-t',
img_type]
if packages:
cmd.append('-p')
cmd.append(','.join(packages))
if docker_target:
cmd.append('--docker-target')
cmd.append(docker_target)
if skip_base == True:
cmd.append('-n')
if options:
cmd.extend(options)
# NODE_DIST provides a distro specific element hook
node_dist = env.get('NODE_DIST')
node_dist = image.get('distro') or env.get('NODE_DIST')
if node_dist:
cmd.append(node_dist)