Merge "Mechanism for Dockerfile customization"

This commit is contained in:
Jenkins 2016-06-12 23:58:54 +00:00 committed by Gerrit Code Review
commit 9afb69c8de
2 changed files with 12 additions and 3 deletions
kolla

@ -142,6 +142,8 @@ _CLI_OPTS = [
help=("Don't build images. Generate Dockerfile only")),
cfg.IntOpt('timeout', default=120,
help='Time in seconds after which any operation times out'),
cfg.StrOpt('template-override',
help='Path to template override file'),
]
_BASE_OPTS = [

@ -613,9 +613,6 @@ class KollaWorker(object):
self.base)
for path in self.docker_build_paths:
template_name = "Dockerfile.j2"
env = jinja2.Environment( # nosec: not used to render HTML
loader=jinja2.FileSystemLoader(path))
template = env.get_template(template_name)
values = {'base_distro': self.base,
'base_image': self.conf.base_image,
'base_distro_tag': self.base_tag,
@ -628,6 +625,16 @@ class KollaWorker(object):
'maintainer': self.maintainer,
'kolla_version': kolla_version,
'rpm_setup': self.rpm_setup}
env = jinja2.Environment( # nosec: not used to render HTML
loader=jinja2.FileSystemLoader(path))
template = env.get_template(template_name)
if self.conf.template_override:
template_path = os.path.dirname(self.conf.template_override)
template_name = os.path.basename(self.conf.template_override)
values['parent_template'] = template
env = jinja2.Environment( # nosec: not used to render HTML
loader=jinja2.FileSystemLoader(template_path))
template = env.get_template(template_name)
if self.include_header:
with open(self.include_header, 'r') as f:
values['include_header'] = f.read()