-
Notifications
You must be signed in to change notification settings - Fork 44
/
build_dockerfile.py
36 lines (33 loc) · 1.15 KB
/
build_dockerfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import json
from jinja2 import Environment, FileSystemLoader
def build_dockerfile(appyter_path, config):
env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))
template = env.get_template('Dockerfile.j2')
dockerfile = template.render(
appyter_path=appyter_path,
config=config,
json=json,
os=os,
)
return dockerfile
def prepare_appyter(appyter_path, config):
import shutil
override_path = os.path.join(appyter_path, 'override')
if os.path.exists(override_path):
shutil.rmtree(override_path)
shutil.copytree(
os.path.join(os.path.dirname(__file__), '..', 'deploy/override'),
os.path.join(appyter_path, 'override'),
)
shutil.copy(
os.path.join(os.path.dirname(__file__), 'catalog_helper.py'),
os.path.join(appyter_path, 'catalog_helper.py')
)
return build_dockerfile(appyter_path, config)
if __name__ == '__main__':
import sys
appyter = sys.argv[1]
appyter_path = os.path.join(os.path.dirname(__file__), '..', 'appyters', appyter)
config = json.load(open(os.path.join(appyter_path, 'appyter.json'), 'r'))
print(prepare_appyter(appyter_path, config))