31 lines
869 B
Python
Executable File
31 lines
869 B
Python
Executable File
from jinja2 import Environment, FileSystemLoader
|
|
import config
|
|
import os
|
|
|
|
# Static Variables
|
|
templates_directory = 'src/templates'
|
|
|
|
# Load Templates Directory
|
|
file_loader = FileSystemLoader(templates_directory)
|
|
env = Environment(loader=file_loader)
|
|
|
|
# Template everyfile
|
|
def template(filename, target_path):
|
|
# Load Template
|
|
template = env.get_template(filename)
|
|
# Render Output
|
|
content = template.render(db=config.db,api=config.api)
|
|
# Write Template to file
|
|
filename_without_ext = os.path.splitext(filename)[0]
|
|
cooked_file = target_path+filename_without_ext
|
|
file = open(cooked_file, 'w')
|
|
file.write(content)
|
|
file.close()
|
|
|
|
# Render the templates:
|
|
## Create Docker-Compose
|
|
template("docker-compose.yml.j2", "./src/")
|
|
## Create API Config
|
|
template(".env.j2", "./bin/")
|
|
## Create Cleanup script
|
|
template("clean-data.sh.j2", "./src/") |