memcached-formula/tools/filltmpl.py

28 lines
587 B
Python
Raw Normal View History

2018-05-18 01:29:00 +02:00
import os
import sys
from jinja2 import Template
# base/tests
dir_path = os.path.dirname(os.path.realpath(__file__))
# base
base_path = os.path.dirname(dir_path)
if __name__ == '__main__':
formula_name = sys.argv[1]
image_tag = sys.argv[2]
template = Template(
open(os.path.join(dir_path, 'templates', 'Dockerfile.j2')).read()
)
dockerfile = template.render({
'formula_name': formula_name,
'image_tag': image_tag
})
with open(os.path.join(base_path, 'Dockerfile.{}'.format(image_tag)), 'w') as fh:
fh.write(dockerfile)