aboutsummaryrefslogtreecommitdiff
path: root/kolla
diff options
context:
space:
mode:
authorMichal (inc0) Jastrzebski <inc007@gmail.com>2016-06-02 16:43:38 +0000
committerMichal (inc0) Jastrzebski <inc007@gmail.com>2016-06-07 21:03:51 +0000
commit51074b0a42490d69f653c49aa78a03cb55888ff1 (patch)
tree003d6ad1f55d9a3da70440571daec123e52fbd9e /kolla
parentc31688be3688d2a4fe24b02aaad7e20ce0a0c516 (diff)
downloadkolla-51074b0a42490d69f653c49aa78a03cb55888ff1.tar.gz
kolla-51074b0a42490d69f653c49aa78a03cb55888ff1.zip
Mechanism for Dockerfile customization
This patchset enables potentially full customization of Dockerfiles provided by Kolla without having to change main Kolla code. Mechanism is based on jinja2 block mechanism. In our dockerfiles we'll add blocks (mostly empty) with highly standarized naming, then in override file users will be able to fill/override contents of these blocks. Example is shown in this patch. To enable cutomized override file call build.py --template-override=path-to-file Only caveat is that header {% extends .. %} has to stay Change-Id: I5957024e5652f9677c439fb2fcd524e467b951af Partially-implements: blueprint third-party-plugin-support
Diffstat (limited to 'kolla')
-rw-r--r--kolla/common/config.py2
-rwxr-xr-xkolla/image/build.py13
2 files changed, 12 insertions, 3 deletions
diff --git a/kolla/common/config.py b/kolla/common/config.py
index 903fd693d..b1224d09e 100644
--- a/kolla/common/config.py
+++ b/kolla/common/config.py
@@ -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 = [
diff --git a/kolla/image/build.py b/kolla/image/build.py
index 40601f0e8..6805ab14c 100755
--- a/kolla/image/build.py
+++ b/kolla/image/build.py
@@ -609,9 +609,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,
@@ -624,6 +621,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()