Merge "Add custom code to base docker templates"

This commit is contained in:
Jenkins 2015-08-21 20:04:59 +00:00 committed by Gerrit Code Review
commit dc2a7a006a
2 changed files with 10 additions and 0 deletions

2
docker_templates/base/Dockerfile.j2 Normal file → Executable file
View File

@ -1,6 +1,8 @@
FROM {{ base_distro }}:{{ base_distro_tag }}
MAINTAINER Kolla Project (https://launchpad.net/kolla)
{{ include_header }}
{% if base_distro in ['fedora', 'centos', 'oraclelinux'] %}
{% if install_type == 'binary' %}
{% if base_distro in ['centos', 'oraclelinux'] %}

View File

@ -173,6 +173,10 @@ def argParser():
parser.add_argument('-d', '--debug',
help='Turn on debugging log level',
action='store_true')
parser.add_argument('-i', '--include-header',
help=('Path to custom file to be added at '
'beginning of base Dockerfile'),
type=str)
return vars(parser.parse_args())
@ -191,6 +195,7 @@ class KollaWorker(object):
self.prefix = self.base + '-' + self.type_ + '-'
self.config = ConfigParser.SafeConfigParser()
self.config.read(os.path.join(sys.path[0], '..', 'build.ini'))
self.include_header = args['include_header']
self.image_statuses_bad = {}
self.image_statuses_good = {}
@ -225,6 +230,9 @@ class KollaWorker(object):
'install_type': self.type_,
'namespace': self.namespace,
'tag': self.tag}
if self.include_header:
with open(self.include_header, 'r') as f:
values['include_header'] = f.read()
content = template.render(values)
with open(os.path.join(path, 'Dockerfile'), 'w') as f:
f.write(content)