Compare commits
4 Commits
0c1cc86e3e
...
f1d29c5ed1
Author | SHA1 | Date | |
---|---|---|---|
f1d29c5ed1 | |||
365fc9405d | |||
a51a89a968 | |||
414473c8c8 |
8
.gitignore
vendored
8
.gitignore
vendored
@ -21,3 +21,11 @@
|
||||
# Go workspace file
|
||||
go.work
|
||||
|
||||
|
||||
# Ignore cached files
|
||||
src/*/cache/*
|
||||
# Ignore pycache bullshit
|
||||
config/__pycache__
|
||||
|
||||
# Template generated files:
|
||||
src/docker-compose.yml
|
17
config/config.py
Normal file
17
config/config.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Checkout the Variables bellow
|
||||
# Special lines:
|
||||
# # => Comented lines, they get ignored by python
|
||||
# #- => Optional Configuration lines
|
||||
|
||||
# Variables
|
||||
|
||||
## Database Variables
|
||||
db = {}
|
||||
#- db['root_pw'] = 'RootPassWord'
|
||||
db['enabled'] = True
|
||||
db['user'] = 'DBUser'
|
||||
db['user_pw'] = 'DBUserPassWord'
|
||||
db['db'] = 'Database Name'
|
||||
#- db['data_path_mysql'] = '/var/lib/mysql'
|
||||
#- db['data_path_mysql_backup'] = '/var/lib/mysql'
|
||||
#- db['port'] = 3306
|
0
config/configfiles.py
Normal file
0
config/configfiles.py
Normal file
27
config/template.py
Executable file
27
config/template.py
Executable file
@ -0,0 +1,27 @@
|
||||
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)
|
||||
# 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/")
|
37
makefile
Normal file
37
makefile
Normal file
@ -0,0 +1,37 @@
|
||||
# Make all
|
||||
all: db api ui
|
||||
|
||||
# Start everything
|
||||
start: db-start api-start ui-start
|
||||
|
||||
# Stop everything
|
||||
stop: ui-stop api-stop db-stop
|
||||
|
||||
# Setup Database
|
||||
db: db-init db-start
|
||||
|
||||
db-init:
|
||||
|
||||
db-start:
|
||||
|
||||
db-stop:
|
||||
|
||||
# Setup API
|
||||
api: api-start
|
||||
|
||||
api-start:
|
||||
|
||||
api-stop:
|
||||
|
||||
# Setup UI
|
||||
ui: ui-start
|
||||
|
||||
ui-start:
|
||||
|
||||
ui-stop:
|
||||
|
||||
# Regenerate configs
|
||||
config: config-regenerate
|
||||
|
||||
config-regenerate:
|
||||
python config/template.py
|
0
src/db/init.sql
Normal file
0
src/db/init.sql
Normal file
33
src/templates/docker-compose.yml.j2
Normal file
33
src/templates/docker-compose.yml.j2
Normal file
@ -0,0 +1,33 @@
|
||||
# Do not adjust this file
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
{% if db.enabled == true %}
|
||||
ngx_mgmt_db:
|
||||
image: mariadb:latest
|
||||
restart: always
|
||||
environment:
|
||||
{% if db.root_pw is defined %}
|
||||
MARIADB_ROOT_PASSWORD: {{ db.root_pw }}
|
||||
{% endif %}
|
||||
MARIADB_USER: {{ TMPL_DB_USER }}
|
||||
MARIADB_PASSWORD: {{ TMPL_DB_USER_PW }}
|
||||
MARIADB_DATABASE: {{ TMPL_DB_DB }}
|
||||
volumes:
|
||||
{% if db.data_path_mysql is defined %}
|
||||
- {{ data_path_mysql }}:/var/lib/mysql
|
||||
{% else %}
|
||||
- ./src/db/cache/mysql_data:/var/lib/mysql
|
||||
{% endif %}
|
||||
{% if db.data_path_mysql_backup is defined %}
|
||||
- {{ data_path_mysql_backup }}:/var/lib/mysql
|
||||
{% else %}
|
||||
- ./src/db/cache/mysql_backup:/var/lib/mysql
|
||||
{% endif %}
|
||||
ports:
|
||||
{% if db.port is defined %}
|
||||
- {{ port }}:3306
|
||||
{% else %}
|
||||
- 3306:3306
|
||||
{% endif %}
|
||||
{% endif %}
|
Loading…
Reference in New Issue
Block a user