Add: Dockerfile

This commit is contained in:
2024-02-09 13:35:44 +05:00
parent f0b7f7e5dc
commit 6775a0df2d
7 changed files with 1270 additions and 42 deletions

View File

@@ -1,43 +1,5 @@
import os
import json
from peewee import Model, MySQLDatabase, CharField, IntegerField
from peewee import Model, MySQLDatabase, CharField
CLIENT_HOST = os.environ.get("CLIENT_HOST", "replace_to_client_host")
PLATFORM = os.environ.get("PLATFORM", "vm") # or dci
DB_ENGINE = os.environ.get("DB_ENGINE", "mysql")
DB_HOST = os.environ.get("DB_HOST", "mysql")
DB_PORT = os.environ.get("DB_PORT", 3306)
DB_USER = os.environ.get("DB_USER", "root")
DB_PASSWORD = os.environ.get("DB_PASSWORD", None) # not secure!!!
DB_NAME = os.environ.get("DB_NAME", "isp") # or auth for dci
if DB_PASSWORD is None:
with open('config.json', 'r') as f:
platform_config = json.load(f)
DB_PASSWORD = platform_config.get("MysqlRootPassword")
# Подключение к базе данных
db = MySQLDatabase(
DB_NAME, **{
'charset': 'utf8',
'sql_mode': 'PIPES_AS_CONCAT',
'use_unicode': True,
'host': DB_HOST,
'port': DB_PORT,
'user': DB_USER,
'password': DB_PASSWORD
}
)
class UnknownField(object):
def __init__(self, *_, **__): pass
class BaseModel(Model):
class Meta:
database = db
class AlertSetting(BaseModel):
channel = UnknownField(null=True) # json