Update: dockerize app, rename pkg to mgrctl, fix imports

This commit is contained in:
2024-06-03 18:58:27 +09:00
parent 34e8118327
commit 0f96d0f956
50 changed files with 309 additions and 94 deletions

View File

@@ -0,0 +1,15 @@
from mgrctl.settings.general import BASE_DIR
from mgrctl.settings.platform import (
PLATFORM_TYPE,
PLATFORM_URL,
PLATFORM_CONFIG
)
from mgrctl.settings.db import(
DB_ENGINE,
DB_HOST,
DB_PORT,
DB_USER,
DB_PASSWORD
)

10
mgrctl/settings/api.py Normal file
View File

@@ -0,0 +1,10 @@
from mgrctl.settings.platform import PLATFORM_TYPE
# Name of nginx container:
INPUT_HOSTNAME = 'input' if PLATFORM_TYPE == 'vm' else 'dci_input_1'
# Port that nginx container is listening:
INPUT_PORT = '1500'
# Headers for internal auth:
HEADERS = {"Internal-Auth": "on", "Accept": "application/json"}

23
mgrctl/settings/db.py Normal file
View File

@@ -0,0 +1,23 @@
from mgrctl.settings.environment import env
from mgrctl.settings.platform import PLATFORM_CONFIG
# ! Required because some instance use psql db:
DB_ENGINE = env.str(
'DB_ENGINE',
PLATFORM_CONFIG.get('DatabaseType', 'mysql')
)
# Connection parameters:
DB_HOST = env.str(
'DB_HOST',
PLATFORM_CONFIG.get('DatabaseType', 'mysql')
)
DB_PORT = env.int('DB_PORT', 3306)
DB_USER = env.str('DB_USER', 'root')
# ! Do not pass password on production. Use value from config.json
DB_PASSWORD = env.str(
'DB_PASSWORD',
PLATFORM_CONFIG.get('MysqlRootPassword', '')
)

View File

@@ -0,0 +1,9 @@
from environs import Env
# Init environment:
env = Env()
# read .env file, if it exists
# reed more about .env file here: https://github.com/sloria/environs
env.read_env()

View File

@@ -0,0 +1,14 @@
import pathlib
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = pathlib.Path(__file__).resolve().parent.parent
INSTALLED_APPS = {
'vm6': {
'auth': 'mgrctl.apps.vm6.auth.commands.cli',
},
'dci6': {
'auth': 'mgrctl.apps.dci6.auth.commands.cli',
},
}

View File

@@ -0,0 +1,17 @@
from mgrctl.settings.environment import env
from mgrctl.utils.helpers import parse_json_file
PLATFORM_TYPE = env.str('PLATFORM_TYPE', 'vm')
PLATFORM_CONFIG = env.str(
'PLATFORM_CONFIG',
f'/opt/ispsystem/{PLATFORM_TYPE}/config.json'
)
PLATFORM_CONFIG = parse_json_file(PLATFORM_CONFIG)
PLATFORM_URL = env.url(
'PLATFORM_URL',
f"https://{PLATFORM_CONFIG.get('DomainName' ,'replace.me')}"
)