Merge pull request 'Bissl docker kram zum laufen gebracht #70-1_docker_and_build' (#76) from #70-1_docker_and_build into #70
Reviewed-on: sh-edraft.de/kd_discord_bot#76
This commit is contained in:
commit
27442fe7c7
@ -12,13 +12,15 @@
|
|||||||
"database": "src/modules/database/database.json",
|
"database": "src/modules/database/database.json",
|
||||||
"moderator": "src/modules/moderator/moderator.json",
|
"moderator": "src/modules/moderator/moderator.json",
|
||||||
"permission": "src/modules/permission/permission.json",
|
"permission": "src/modules/permission/permission.json",
|
||||||
"bot-api": "src/bot_api/bot-api.json"
|
"bot-api": "src/bot_api/bot-api.json",
|
||||||
|
"post-build": "tools/post_build/post-build.json"
|
||||||
},
|
},
|
||||||
"Scripts": {
|
"Scripts": {
|
||||||
|
"post-build": "cpl run post-build",
|
||||||
"prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;",
|
"prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;",
|
||||||
"stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;",
|
"stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;",
|
||||||
"dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;",
|
"dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;",
|
||||||
"build-docker": "cpl b; docker-compose down; docker build -t kdb .",
|
"build-docker": "cpl b; docker-compose down; docker build -t kdb:kdb .",
|
||||||
"compose": "docker-compose up -d",
|
"compose": "docker-compose up -d",
|
||||||
"docker": "cpl build-docker; cpl compose;"
|
"docker": "cpl build-docker; cpl compose;"
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,12 @@ version: "3.9"
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
kdb_prod_1:
|
kdb_prod_1:
|
||||||
kdb_staging_1:
|
kdb_web_prod_1:
|
||||||
kdb_db_1:
|
kdb_db_1:
|
||||||
kdb_db_2:
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
kdb_prod_1:
|
kdb_prod_1:
|
||||||
image: kdb/kdb:0.2.1
|
image: kdb/kdb:0.3
|
||||||
container_name: kdb_prod_1
|
container_name: kdb_prod_1
|
||||||
depends_on:
|
depends_on:
|
||||||
- kdb_db_1
|
- kdb_db_1
|
||||||
@ -20,18 +19,16 @@ services:
|
|||||||
KDB_PREFIX: "!k "
|
KDB_PREFIX: "!k "
|
||||||
restart: 'no'
|
restart: 'no'
|
||||||
|
|
||||||
kdb_staging_1:
|
kdb_web_prod_1:
|
||||||
image: kdb/kdb:0.2.1
|
image: kdb/kdb-web:0.3
|
||||||
container_name: kdb_staging_1
|
container_name: kdb_web_prod_1
|
||||||
depends_on:
|
depends_on:
|
||||||
- kdb_db_1
|
- kdb_prod_1
|
||||||
volumes:
|
volumes:
|
||||||
- kdb_staging_1:/app
|
- kdb_web_prod_1:/app
|
||||||
environment:
|
|
||||||
KDB_ENVIRONMENT: "staging"
|
|
||||||
KDB_TOKEN: ""
|
|
||||||
KDB_PREFIX: "!kt "
|
|
||||||
restart: 'no'
|
restart: 'no'
|
||||||
|
ports:
|
||||||
|
- '8042:80'
|
||||||
|
|
||||||
kdb_db_1:
|
kdb_db_1:
|
||||||
image: mysql:latest
|
image: mysql:latest
|
||||||
@ -47,18 +44,3 @@ services:
|
|||||||
- "3307:3306"
|
- "3307:3306"
|
||||||
volumes:
|
volumes:
|
||||||
- kdb_db_1:/var/lib/mysql
|
- kdb_db_1:/var/lib/mysql
|
||||||
|
|
||||||
kdb_db_2:
|
|
||||||
image: mysql:latest
|
|
||||||
container_name: kdb_db_2
|
|
||||||
command: mysqld --default-authentication-plugin=mysql_native_password
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: "kd_kdb"
|
|
||||||
MYSQL_USER: "kd_kdb"
|
|
||||||
MYSQL_PASSWORD: "kd_kdb"
|
|
||||||
MYSQL_DATABASE: "kd_kdb"
|
|
||||||
ports:
|
|
||||||
- "3308:3306"
|
|
||||||
volumes:
|
|
||||||
- kdb_db_2:/var/lib/mysql
|
|
@ -4,10 +4,7 @@ FROM python:3.10.7-bullseye
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY ./dist/bot/build/ .
|
COPY ./dist/bot/build/ .
|
||||||
|
|
||||||
RUN pip install cpl-core --extra-index-url https://pip.sh-edraft.de
|
RUN pip install -r requirements.txt --extra-index-url https://pip.sh-edraft.de
|
||||||
RUN pip install cpl-discord --extra-index-url https://pip.sh-edraft.de
|
|
||||||
RUN pip install cpl-query --extra-index-url https://pip.sh-edraft.de
|
|
||||||
RUN pip install cpl-translation --extra-index-url https://pip.sh-edraft.de
|
|
||||||
RUN apt-get update -y
|
RUN apt-get update -y
|
||||||
RUN apt-get install nano -y
|
RUN apt-get install nano -y
|
||||||
|
|
||||||
|
@ -33,9 +33,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "bot-api",
|
"Name": "bot-api",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "0",
|
"Major": "1",
|
||||||
"Minor": "0",
|
"Minor": "0",
|
||||||
"Micro": "0"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
@ -22,9 +22,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
bot Keksdose bot
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Discord bot for the Keksdose discord Server
|
||||||
|
|
||||||
|
:copyright: (c) 2022 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'bot_api.controller.discord'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||||
|
__version__ = '0.3.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='0', minor='3', micro='0')
|
@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
bot Keksdose bot
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Discord bot for the Keksdose discord Server
|
||||||
|
|
||||||
|
:copyright: (c) 2022 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'bot_api.event'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||||
|
__version__ = '0.3.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='0', minor='3', micro='0')
|
@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
bot Keksdose bot
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Discord bot for the Keksdose discord Server
|
||||||
|
|
||||||
|
:copyright: (c) 2022 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'bot_api.filter.discord'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||||
|
__version__ = '0.3.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='0', minor='3', micro='0')
|
@ -1 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
bot Keksdose bot
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Discord bot for the Keksdose discord Server
|
||||||
|
|
||||||
|
:copyright: (c) 2022 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'bot_api.mail'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||||
|
__version__ = '0.3.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='0', minor='3', micro='0')
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
bot Keksdose bot
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Discord bot for the Keksdose discord Server
|
||||||
|
|
||||||
|
:copyright: (c) 2022 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'bot_api.model.discord'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||||
|
__version__ = '0.3.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='0', minor='3', micro='0')
|
@ -22,9 +22,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
@ -22,9 +22,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "admin",
|
"Name": "admin",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "0",
|
"Major": "1",
|
||||||
"Minor": "0",
|
"Minor": "0",
|
||||||
"Micro": "0"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
@ -22,9 +22,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "auto-role",
|
"Name": "auto-role",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "0",
|
"Major": "1",
|
||||||
"Minor": "0",
|
"Minor": "0",
|
||||||
"Micro": "0"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
@ -22,9 +22,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "base",
|
"Name": "base",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "0",
|
"Major": "1",
|
||||||
"Minor": "0",
|
"Minor": "0",
|
||||||
"Micro": "0"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
@ -22,9 +22,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "boot-log",
|
"Name": "boot-log",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "0",
|
"Major": "1",
|
||||||
"Minor": "0",
|
"Minor": "0",
|
||||||
"Micro": "0"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
@ -22,9 +22,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
@ -22,9 +22,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "moderator",
|
"Name": "moderator",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "0",
|
"Major": "1",
|
||||||
"Minor": "0",
|
"Minor": "0",
|
||||||
"Micro": "0"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
@ -22,9 +22,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"ProjectSettings": {
|
"ProjectSettings": {
|
||||||
"Name": "permission",
|
"Name": "permission",
|
||||||
"Version": {
|
"Version": {
|
||||||
"Major": "0",
|
"Major": "1",
|
||||||
"Minor": "0",
|
"Minor": "0",
|
||||||
"Micro": "0"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
@ -22,9 +22,7 @@
|
|||||||
"cpl-cli==2022.10.0"
|
"cpl-cli==2022.10.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.10.4",
|
"PythonVersion": ">=3.10.4",
|
||||||
"PythonPath": {
|
"PythonPath": {},
|
||||||
"linux": ""
|
|
||||||
},
|
|
||||||
"Classifiers": []
|
"Classifiers": []
|
||||||
},
|
},
|
||||||
"BuildSettings": {
|
"BuildSettings": {
|
||||||
|
26
kdb-bot/tools/post_build/__init__.py
Normal file
26
kdb-bot/tools/post_build/__init__.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
post-build KDB - post build
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Tool project to clean build project files
|
||||||
|
|
||||||
|
:copyright: (c) 2022 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'post_build'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||||
|
__version__ = '1.0.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='1', minor='0', micro='0')
|
26
kdb-bot/tools/post_build/application.py
Normal file
26
kdb-bot/tools/post_build/application.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from cpl_core.application import ApplicationABC
|
||||||
|
from cpl_core.configuration import ConfigurationABC
|
||||||
|
from cpl_core.console import Console
|
||||||
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
|
|
||||||
|
from post_build.service.dependencies import Dependencies
|
||||||
|
from post_build.service.remove_config import RemoveConfig
|
||||||
|
|
||||||
|
|
||||||
|
class Application(ApplicationABC):
|
||||||
|
|
||||||
|
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||||
|
ApplicationABC.__init__(self, config, services)
|
||||||
|
|
||||||
|
self._remove_config: RemoveConfig = services.get_service(RemoveConfig)
|
||||||
|
self._deps: Dependencies = services.get_service(Dependencies)
|
||||||
|
|
||||||
|
def configure(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
Console.write_line('KDB Post-Build:')
|
||||||
|
Console.spinner(f'Removing unnecessary configs', self._remove_config.remove)
|
||||||
|
Console.spinner(f'Creating requirements file for pip', self._deps.create)
|
||||||
|
|
||||||
|
|
30
kdb-bot/tools/post_build/appsettings.json
Normal file
30
kdb-bot/tools/post_build/appsettings.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"TimeFormatSettings": {
|
||||||
|
"DateFormat": "%Y-%m-%d",
|
||||||
|
"TimeFormat": "%H:%M:%S",
|
||||||
|
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||||
|
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||||
|
},
|
||||||
|
|
||||||
|
"LoggingSettings": {
|
||||||
|
"Path": "logs/",
|
||||||
|
"Filename": "log_$start_time.log",
|
||||||
|
"ConsoleLogLevel": "ERROR",
|
||||||
|
"FileLogLevel": "WARN"
|
||||||
|
},
|
||||||
|
|
||||||
|
"PostBuild": {
|
||||||
|
"KeepConfigs": [
|
||||||
|
"appsettings.json",
|
||||||
|
"appsettings.staging.json",
|
||||||
|
"appsettings.production.json",
|
||||||
|
"apisettings.json",
|
||||||
|
"apisettings.staging.json",
|
||||||
|
"apisettings.production.json"
|
||||||
|
],
|
||||||
|
"ConfigPaths": [
|
||||||
|
"bot/config/",
|
||||||
|
"bot_api/config/"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
14
kdb-bot/tools/post_build/main.py
Normal file
14
kdb-bot/tools/post_build/main.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from cpl_core.application import ApplicationBuilder
|
||||||
|
|
||||||
|
from post_build.application import Application
|
||||||
|
from post_build.startup import Startup
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
app_builder = ApplicationBuilder(Application)
|
||||||
|
app_builder.use_startup(Startup)
|
||||||
|
app_builder.build().run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
44
kdb-bot/tools/post_build/post-build.json
Normal file
44
kdb-bot/tools/post_build/post-build.json
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"ProjectSettings": {
|
||||||
|
"Name": "post-build",
|
||||||
|
"Version": {
|
||||||
|
"Major": "1",
|
||||||
|
"Minor": "0",
|
||||||
|
"Micro": "0"
|
||||||
|
},
|
||||||
|
"Author": "Sven Heidemann",
|
||||||
|
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||||
|
"Description": "KDB - post build",
|
||||||
|
"LongDescription": "Tool project to clean build project files",
|
||||||
|
"URL": "https://www.sh-edraft.de",
|
||||||
|
"CopyrightDate": "2022",
|
||||||
|
"CopyrightName": "sh-edraft.de",
|
||||||
|
"LicenseName": "MIT",
|
||||||
|
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||||
|
"Dependencies": [
|
||||||
|
"cpl-core>=2022.10.0.post7"
|
||||||
|
],
|
||||||
|
"DevDependencies": [
|
||||||
|
"cpl-cli>=2022.10.0"
|
||||||
|
],
|
||||||
|
"PythonVersion": ">=3.10.4",
|
||||||
|
"PythonPath": {},
|
||||||
|
"Classifiers": []
|
||||||
|
},
|
||||||
|
"BuildSettings": {
|
||||||
|
"ProjectType": "console",
|
||||||
|
"SourcePath": "",
|
||||||
|
"OutputPath": "../../dist",
|
||||||
|
"Main": "post_build.main",
|
||||||
|
"EntryPoint": "post-build",
|
||||||
|
"IncludePackageData": false,
|
||||||
|
"Included": [],
|
||||||
|
"Excluded": [
|
||||||
|
"*/__pycache__",
|
||||||
|
"*/logs",
|
||||||
|
"*/tests"
|
||||||
|
],
|
||||||
|
"PackageData": {},
|
||||||
|
"ProjectReferences": []
|
||||||
|
}
|
||||||
|
}
|
29
kdb-bot/tools/post_build/post_build_settings.py
Normal file
29
kdb-bot/tools/post_build/post_build_settings.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import traceback
|
||||||
|
|
||||||
|
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||||
|
from cpl_core.console import Console
|
||||||
|
|
||||||
|
|
||||||
|
class PostBuildSettings(ConfigurationModelABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
ConfigurationModelABC.__init__(self)
|
||||||
|
|
||||||
|
self._keep_config = []
|
||||||
|
self._config_paths = []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def keep_config(self) -> list[str]:
|
||||||
|
return self._keep_config
|
||||||
|
|
||||||
|
@property
|
||||||
|
def config_paths(self) -> list[str]:
|
||||||
|
return self._config_paths
|
||||||
|
|
||||||
|
def from_dict(self, settings: dict):
|
||||||
|
try:
|
||||||
|
self._keep_config = settings['KeepConfigs']
|
||||||
|
self._config_paths = settings['ConfigPaths']
|
||||||
|
except Exception as e:
|
||||||
|
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings')
|
||||||
|
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
26
kdb-bot/tools/post_build/service/__init__.py
Normal file
26
kdb-bot/tools/post_build/service/__init__.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
post-build KDB - post build
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Tool project to clean build project files
|
||||||
|
|
||||||
|
:copyright: (c) 2022 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'post_build.service'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||||
|
__version__ = '1.0.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
|
# imports
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='1', minor='0', micro='0')
|
64
kdb-bot/tools/post_build/service/dependencies.py
Normal file
64
kdb-bot/tools/post_build/service/dependencies.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from cpl_cli.configuration import WorkspaceSettings, ProjectSettings, BuildSettings
|
||||||
|
from cpl_core.configuration import ConfigurationABC
|
||||||
|
from cpl_core.console import Console
|
||||||
|
from cpl_core.environment import ApplicationEnvironmentABC
|
||||||
|
|
||||||
|
from post_build.post_build_settings import PostBuildSettings
|
||||||
|
|
||||||
|
|
||||||
|
class Dependencies:
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
config: ConfigurationABC,
|
||||||
|
env: ApplicationEnvironmentABC,
|
||||||
|
ws: WorkspaceSettings,
|
||||||
|
project: ProjectSettings,
|
||||||
|
build: BuildSettings,
|
||||||
|
post_build: PostBuildSettings
|
||||||
|
):
|
||||||
|
self._config = config
|
||||||
|
self._env = env
|
||||||
|
self._workspace = ws
|
||||||
|
self._project = project
|
||||||
|
self._build = build
|
||||||
|
self._post_build = post_build
|
||||||
|
|
||||||
|
self._dependencies = {}
|
||||||
|
|
||||||
|
def _add_dependencies(self, deps: list[str]):
|
||||||
|
for d in deps:
|
||||||
|
d_name = d
|
||||||
|
if '>=' in d:
|
||||||
|
d_name = d.split('>=')[0]
|
||||||
|
if '<=' in d:
|
||||||
|
d_name = d.split('<=')[0]
|
||||||
|
if '==' in d:
|
||||||
|
d_name = d.split('==')[0]
|
||||||
|
|
||||||
|
if d_name in self._dependencies:
|
||||||
|
continue
|
||||||
|
|
||||||
|
self._dependencies[d_name] = d
|
||||||
|
|
||||||
|
def create(self):
|
||||||
|
dist_path = os.path.abspath(os.path.join(
|
||||||
|
self._env.working_directory,
|
||||||
|
os.path.dirname(self._workspace.projects[self._project.name]),
|
||||||
|
self._build.output_path,
|
||||||
|
self._project.name,
|
||||||
|
'build'
|
||||||
|
))
|
||||||
|
|
||||||
|
for project in self._workspace.projects:
|
||||||
|
project_file = os.path.join(self._env.working_directory, self._workspace.projects[project])
|
||||||
|
self._config.add_json_file(project_file, output=False, optional=False)
|
||||||
|
project: ProjectSettings = self._config.get_configuration(ProjectSettings)
|
||||||
|
self._add_dependencies(project.dependencies)
|
||||||
|
|
||||||
|
with open(f'{dist_path}/requirements.txt', 'w+', encoding='utf-8') as f:
|
||||||
|
for dependency in self._dependencies:
|
||||||
|
f.write(f'{self._dependencies[dependency]}\n')
|
||||||
|
f.close()
|
39
kdb-bot/tools/post_build/service/remove_config.py
Normal file
39
kdb-bot/tools/post_build/service/remove_config.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from cpl_cli.configuration import ProjectSettings, BuildSettings, WorkspaceSettings
|
||||||
|
from cpl_core.console import Console
|
||||||
|
from cpl_core.environment import ApplicationEnvironmentABC
|
||||||
|
|
||||||
|
from post_build.post_build_settings import PostBuildSettings
|
||||||
|
|
||||||
|
|
||||||
|
class RemoveConfig:
|
||||||
|
|
||||||
|
def __init__(self, env: ApplicationEnvironmentABC, ws: WorkspaceSettings, project: ProjectSettings, build: BuildSettings, post_build: PostBuildSettings):
|
||||||
|
|
||||||
|
self._env = env
|
||||||
|
self._workspace = ws
|
||||||
|
self._project = project
|
||||||
|
self._build = build
|
||||||
|
self._post_build = post_build
|
||||||
|
|
||||||
|
def remove(self):
|
||||||
|
dist_path = os.path.abspath(os.path.join(
|
||||||
|
self._env.working_directory,
|
||||||
|
os.path.dirname(self._workspace.projects[self._project.name]),
|
||||||
|
self._build.output_path,
|
||||||
|
self._project.name,
|
||||||
|
'build'
|
||||||
|
))
|
||||||
|
|
||||||
|
for cfg_path in self._post_build.config_paths:
|
||||||
|
config_path = os.path.join(
|
||||||
|
dist_path,
|
||||||
|
cfg_path
|
||||||
|
)
|
||||||
|
for r, d, f in os.walk(config_path):
|
||||||
|
for file in f:
|
||||||
|
if file in self._post_build.keep_config:
|
||||||
|
continue
|
||||||
|
|
||||||
|
os.remove(os.path.abspath(os.path.join(config_path, file)))
|
32
kdb-bot/tools/post_build/startup.py
Normal file
32
kdb-bot/tools/post_build/startup.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import os.path
|
||||||
|
|
||||||
|
from cpl_cli.configuration import WorkspaceSettings, ProjectSettings
|
||||||
|
from cpl_core.application import StartupABC
|
||||||
|
from cpl_core.configuration import ConfigurationABC
|
||||||
|
from cpl_core.console import Console
|
||||||
|
from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||||
|
from cpl_core.environment import ApplicationEnvironment
|
||||||
|
|
||||||
|
from post_build.service.dependencies import Dependencies
|
||||||
|
from post_build.service.remove_config import RemoveConfig
|
||||||
|
|
||||||
|
|
||||||
|
class Startup(StartupABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
StartupABC.__init__(self)
|
||||||
|
|
||||||
|
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||||
|
configuration.add_json_file(f'appsettings.json', optional=False, output=False)
|
||||||
|
environment.set_working_directory(os.path.abspath(os.path.join(environment.working_directory, '../../')))
|
||||||
|
configuration.add_json_file(f'cpl-workspace.json', optional=False, output=False)
|
||||||
|
ws: WorkspaceSettings = configuration.get_configuration(WorkspaceSettings)
|
||||||
|
configuration.add_json_file(ws.projects[ws.default_project], optional=False, output=False)
|
||||||
|
|
||||||
|
return configuration
|
||||||
|
|
||||||
|
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||||
|
services.add_transient(RemoveConfig)
|
||||||
|
services.add_transient(Dependencies)
|
||||||
|
|
||||||
|
return services.build_service_provider()
|
@ -40,8 +40,8 @@
|
|||||||
"budgets": [
|
"budgets": [
|
||||||
{
|
{
|
||||||
"type": "initial",
|
"type": "initial",
|
||||||
"maximumWarning": "500kb",
|
"maximumWarning": "8mb",
|
||||||
"maximumError": "1mb"
|
"maximumError": "16mb"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "anyComponentStyle",
|
"type": "anyComponentStyle",
|
||||||
|
2
kdb-web/dockerfile
Normal file
2
kdb-web/dockerfile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
COPY ./dist/kdb-web/ /usr/share/nginx/html
|
@ -9,7 +9,8 @@
|
|||||||
"prebuild": "npm run update-version",
|
"prebuild": "npm run update-version",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "ng test"
|
"test": "ng test",
|
||||||
|
"build-docker": "ng build; docker build -t kdb-web:kdb-web ."
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user