Compare commits
13 Commits
82058bab0e
...
0037a30c11
Author | SHA1 | Date | |
---|---|---|---|
0037a30c11 | |||
77e079d91c | |||
0a0401dd87 | |||
69fc75fc97 | |||
5a85232374 | |||
5892b209d3 | |||
6715ecacd6 | |||
d72715d51b | |||
a7f9fa5818 | |||
c45916aaee | |||
8bbd57e82f | |||
987a1a664b | |||
99bfa9874a |
65
.gitea/workflows/deploy_prod.yaml
Normal file
65
.gitea/workflows/deploy_prod.yaml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
name: Deploy dev on push
|
||||||
|
run-name: Deploy dev on push
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
on-push-deploy_sh-edraft:
|
||||||
|
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||||
|
container: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Setup Python 3.10
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: "3.10.12"
|
||||||
|
- run: python -v
|
||||||
|
|
||||||
|
- name: Setup docker
|
||||||
|
uses: https://github.com/papodaca/install-docker-action@main
|
||||||
|
- run: docker -v
|
||||||
|
|
||||||
|
- name: Clone Repository
|
||||||
|
uses: https://github.com/actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Shutdown stack
|
||||||
|
run: docker stack rm kdb_prod
|
||||||
|
|
||||||
|
- name: Prepare bot build
|
||||||
|
run: |
|
||||||
|
cd kdb-bot
|
||||||
|
pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||||
|
cpl i
|
||||||
|
|
||||||
|
- name: Build docker bot
|
||||||
|
run: |
|
||||||
|
cd kdb-bot
|
||||||
|
docker image prune -f
|
||||||
|
cpl docker-build
|
||||||
|
|
||||||
|
- name: Setup node
|
||||||
|
uses: https://github.com/actions/setup-node@v3
|
||||||
|
|
||||||
|
- name: Prepare web build
|
||||||
|
run: |
|
||||||
|
cd kdb-web
|
||||||
|
npm install -g ts-node
|
||||||
|
npm i
|
||||||
|
|
||||||
|
- name: Build docker web
|
||||||
|
run: |
|
||||||
|
cd kdb-web
|
||||||
|
docker image prune -f
|
||||||
|
npm run docker-build
|
||||||
|
|
||||||
|
- name: Deploy Stack to sh-edraft.de
|
||||||
|
uses: https://github.com/kgierke/portainer-stack-deployment@v1
|
||||||
|
with:
|
||||||
|
portainer-url: "https://docker.sh-edraft.de"
|
||||||
|
portainer-username: "gitea_job"
|
||||||
|
portainer-password: "${{ secrets.docker_job }}"
|
||||||
|
portainer-endpoint: 2
|
||||||
|
name: kdb_prod
|
||||||
|
file: ./docker-compose.yml
|
||||||
|
variables: '{}'
|
65
.gitea/workflows/deploy_support.yaml
Normal file
65
.gitea/workflows/deploy_support.yaml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
name: Deploy dev on push
|
||||||
|
run-name: Deploy dev on push
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- support
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
on-push-deploy_sh-edraft:
|
||||||
|
runs-on: [ dobby.sh-edraft.de, ubuntu-latest ]
|
||||||
|
container: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Setup Python 3.10
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: "3.10.12"
|
||||||
|
- run: python -v
|
||||||
|
|
||||||
|
- name: Setup docker
|
||||||
|
uses: https://github.com/papodaca/install-docker-action@main
|
||||||
|
- run: docker -v
|
||||||
|
|
||||||
|
- name: Clone Repository
|
||||||
|
uses: https://github.com/actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Shutdown stack
|
||||||
|
run: docker stack rm kdb_staging
|
||||||
|
|
||||||
|
- name: Prepare bot build
|
||||||
|
run: |
|
||||||
|
cd kdb-bot
|
||||||
|
pip install --extra-index-url https://pip.sh-edraft.de cpl-cli
|
||||||
|
cpl i
|
||||||
|
|
||||||
|
- name: Build docker bot
|
||||||
|
run: |
|
||||||
|
cd kdb-bot
|
||||||
|
docker image prune -f
|
||||||
|
cpl docker-build
|
||||||
|
|
||||||
|
- name: Setup node
|
||||||
|
uses: https://github.com/actions/setup-node@v3
|
||||||
|
|
||||||
|
- name: Prepare web build
|
||||||
|
run: |
|
||||||
|
cd kdb-web
|
||||||
|
npm install -g ts-node
|
||||||
|
npm i
|
||||||
|
|
||||||
|
- name: Build docker web
|
||||||
|
run: |
|
||||||
|
cd kdb-web
|
||||||
|
docker image prune -f
|
||||||
|
npm run docker-build
|
||||||
|
|
||||||
|
- name: Deploy Stack to sh-edraft.de
|
||||||
|
uses: https://github.com/kgierke/portainer-stack-deployment@v1
|
||||||
|
with:
|
||||||
|
portainer-url: "https://docker.sh-edraft.de"
|
||||||
|
portainer-username: "gitea_job"
|
||||||
|
portainer-password: "${{ secrets.docker_job }}"
|
||||||
|
portainer-endpoint: 2
|
||||||
|
name: kdb_staging
|
||||||
|
file: ./docker-compose.staging.yml
|
||||||
|
variables: '{}'
|
89
docker-compose.staging.yml
Normal file
89
docker-compose.staging.yml
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
kdb_db_staging_1:
|
||||||
|
|
||||||
|
services:
|
||||||
|
kdb_bot_staging_1:
|
||||||
|
image: sh-edraft.de/kdb-bot:1.1.6
|
||||||
|
container_name: kdb_bot_staging_1
|
||||||
|
depends_on:
|
||||||
|
- kdb_db_staging_1
|
||||||
|
networks:
|
||||||
|
- kdb_test
|
||||||
|
- reverse_proxy
|
||||||
|
volumes:
|
||||||
|
- /opt/kdb/staging/bot/config:/app/bot/config
|
||||||
|
- /opt/kdb/staging/bot/api_config:/app/bot_api/config
|
||||||
|
- /opt/kdb/staging/bot/logs:/app/bot/logs
|
||||||
|
environment:
|
||||||
|
KDB_ENVIRONMENT: "staging"
|
||||||
|
KDB_TOKEN: "OTk4MTU5ODAyMzkzOTY0NTk0.G-csct.b2Y-HxvLz0SfFLl5HpukROv2GaiWhcMABbMzYE"
|
||||||
|
KDB_PREFIX: "!kt "
|
||||||
|
command: bash /app/bot/bot -stage
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
placement:
|
||||||
|
constraints: [ node.role == manager ]
|
||||||
|
resources:
|
||||||
|
reservations:
|
||||||
|
cpus: "0.5"
|
||||||
|
memory: 1024M
|
||||||
|
|
||||||
|
kdb_web_staging_1:
|
||||||
|
image: sh-edraft.de/kdb-web:1.1.6
|
||||||
|
container_name: kdb_web_staging_1
|
||||||
|
depends_on:
|
||||||
|
- kdb_bot_staging_1
|
||||||
|
networks:
|
||||||
|
- kdb_test
|
||||||
|
- reverse_proxy
|
||||||
|
volumes:
|
||||||
|
- /opt/kdb/staging/web/config.json:/usr/share/nginx/html/assets/config.json
|
||||||
|
environment:
|
||||||
|
BOT_CONTAINER_NAME: "kdb_bot_staging_1"
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
placement:
|
||||||
|
constraints: [ node.role == manager ]
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "0.4"
|
||||||
|
memory: 400M
|
||||||
|
reservations:
|
||||||
|
cpus: "0.1"
|
||||||
|
memory: 20M
|
||||||
|
|
||||||
|
kdb_db_staging_1:
|
||||||
|
image: mysql:latest
|
||||||
|
container_name: kdb_db_staging_1
|
||||||
|
command: mysqld --default-authentication-plugin=mysql_native_password --log_bin_trust_function_creators=1
|
||||||
|
networks:
|
||||||
|
- kdb_test
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: "kd_kdb"
|
||||||
|
MYSQL_USER: "kd_kdb"
|
||||||
|
MYSQL_PASSWORD: "~qELxjvtjJ3r7yg4PZr5!,V}d.{TC4rg"
|
||||||
|
MYSQL_DATABASE: "kd_kdb"
|
||||||
|
ports:
|
||||||
|
- "3308:3306"
|
||||||
|
volumes:
|
||||||
|
- kdb_db_staging_1:/var/lib/mysql
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
placement:
|
||||||
|
constraints: [ node.role == manager ]
|
||||||
|
resources:
|
||||||
|
reservations:
|
||||||
|
cpus: "0.1"
|
||||||
|
memory: 150M
|
||||||
|
|
||||||
|
networks:
|
||||||
|
reverse_proxy:
|
||||||
|
external: true
|
||||||
|
kdb_test:
|
||||||
|
driver: overlay
|
||||||
|
attachable: true
|
86
docker-compose.yml
Normal file
86
docker-compose.yml
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
kdb_db_prod_1:
|
||||||
|
|
||||||
|
services:
|
||||||
|
kdb_bot_prod_1:
|
||||||
|
image: sh-edraft.de/kdb-bot:1.1.6
|
||||||
|
depends_on:
|
||||||
|
- kdb_db_prod_1
|
||||||
|
networks:
|
||||||
|
- kdb_prod
|
||||||
|
- reverse_proxy
|
||||||
|
volumes:
|
||||||
|
- /opt/kdb/production/bot/config:/app/bot/config
|
||||||
|
- /opt/kdb/production/bot/api_config:/app/bot_api/config
|
||||||
|
- /opt/kdb/production/bot/logs:/app/bot/logs
|
||||||
|
environment:
|
||||||
|
KDB_ENVIRONMENT: "production"
|
||||||
|
KDB_TOKEN: "OTk4MTU5NTEyNDYyNzA4Nzg2.Gx0hSB.Ouq2dfRKxLBJvHfEq8OrFBHVUF24AQrVf55coM"
|
||||||
|
KDB_PREFIX: "!k "
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
placement:
|
||||||
|
constraints: [ node.role == manager ]
|
||||||
|
resources:
|
||||||
|
reservations:
|
||||||
|
cpus: "0.5"
|
||||||
|
memory: 1024M
|
||||||
|
|
||||||
|
kdb_web_prod_1:
|
||||||
|
image: sh-edraft.de/kdb-web:1.1.6
|
||||||
|
depends_on:
|
||||||
|
- kdb_bot_prod_1
|
||||||
|
networks:
|
||||||
|
- kdb_prod
|
||||||
|
- reverse_proxy
|
||||||
|
volumes:
|
||||||
|
- /opt/kdb/production/web/config.json:/usr/share/nginx/html/assets/config.json
|
||||||
|
environment:
|
||||||
|
BOT_CONTAINER_NAME: "kdb_bot_prod_1"
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
placement:
|
||||||
|
constraints: [ node.role == manager ]
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "0.4"
|
||||||
|
memory: 400M
|
||||||
|
reservations:
|
||||||
|
cpus: "0.1"
|
||||||
|
memory: 20M
|
||||||
|
|
||||||
|
kdb_db_prod_1:
|
||||||
|
image: mysql:latest
|
||||||
|
command: mysqld --default-authentication-plugin=mysql_native_password --log_bin_trust_function_creators=1
|
||||||
|
networks:
|
||||||
|
- kdb_prod
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: "kd_kdb"
|
||||||
|
MYSQL_USER: "kd_kdb"
|
||||||
|
MYSQL_PASSWORD: ",2#MzfN4J=7r(q,Tz3npDkCR§>VE&}7T"
|
||||||
|
MYSQL_DATABASE: "kd_kdb"
|
||||||
|
ports:
|
||||||
|
- "3307:3306"
|
||||||
|
volumes:
|
||||||
|
- kdb_db_prod_1:/var/lib/mysql
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
placement:
|
||||||
|
constraints: [ node.role == manager ]
|
||||||
|
resources:
|
||||||
|
reservations:
|
||||||
|
cpus: "0.1"
|
||||||
|
memory: 150M
|
||||||
|
|
||||||
|
networks:
|
||||||
|
reverse_proxy:
|
||||||
|
external: true
|
||||||
|
kdb_prod:
|
||||||
|
driver: overlay
|
||||||
|
attachable: true
|
@ -35,7 +35,7 @@
|
|||||||
"stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;",
|
"stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;",
|
||||||
"pre-dev": "cpl build",
|
"pre-dev": "cpl build",
|
||||||
"dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;",
|
"dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;",
|
||||||
"docker-build": "cpl build $ARGS; docker build -t kdb-bot/kdb-bot:$(cpl gv) .;",
|
"docker-build": "cpl build $ARGS; docker build -t sh-edraft.de/kdb-bot:$(cpl gv) .;",
|
||||||
"dc-up": "docker-compose up -d",
|
"dc-up": "docker-compose up -d",
|
||||||
"dc-down": "docker-compose down",
|
"dc-down": "docker-compose down",
|
||||||
"docker": "cpl dc-down; cpl docker-build; cpl dc-up;"
|
"docker": "cpl dc-down; cpl docker-build; cpl dc-up;"
|
||||||
|
@ -48,6 +48,7 @@ class ServerConfigSeeder(DataSeederABC):
|
|||||||
guild.system_channel.id,
|
guild.system_channel.id,
|
||||||
guild.system_channel.id,
|
guild.system_channel.id,
|
||||||
guild.system_channel.id,
|
guild.system_channel.id,
|
||||||
|
guild.default_role.id,
|
||||||
{},
|
{},
|
||||||
server,
|
server,
|
||||||
[],
|
[],
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import discord
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
from discord import Guild
|
from discord import Guild
|
||||||
@ -17,22 +18,24 @@ class GuildQuery(QueryABC):
|
|||||||
self.set_field("id", lambda g, *_: g.id)
|
self.set_field("id", lambda g, *_: g.id)
|
||||||
self.set_field("name", lambda g, *_: g.name)
|
self.set_field("name", lambda g, *_: g.name)
|
||||||
self.set_field("channels", self._resolve_channels)
|
self.set_field("channels", self._resolve_channels)
|
||||||
self.set_field("roles", lambda g, *_: g.roles)
|
self.set_field("roles", lambda g, *_: g.roles.order_by(lambda x: x.position))
|
||||||
self.set_field("emojis", lambda g, *_: g.emojis)
|
self.set_field(
|
||||||
|
"emojis", lambda g, *_: List(discord.Emoji, g.emojis).order_by_descending(lambda x: x.created_at)
|
||||||
|
)
|
||||||
|
|
||||||
def _resolve_channels(self, g: Guild, *_, filter=None):
|
def _resolve_channels(self, g: Guild, *_, filter=None):
|
||||||
users = List(any).extend(g.channels)
|
channels = List(any).extend(g.channels)
|
||||||
|
|
||||||
if filter is None:
|
if filter is None:
|
||||||
return users
|
return channels
|
||||||
|
|
||||||
if "id" in filter:
|
if "id" in filter:
|
||||||
users = users.where(lambda c: c.id == int(filter["id"]))
|
channels = channels.where(lambda c: c.id == int(filter["id"]))
|
||||||
|
|
||||||
if "name" in filter:
|
if "name" in filter:
|
||||||
users = users.where(lambda c: c.id == filter["name"])
|
channels = channels.where(lambda c: c.id == filter["name"])
|
||||||
|
|
||||||
if "type" in filter:
|
if "type" in filter:
|
||||||
users = users.where(lambda c: type(c).__name__ == filter["type"])
|
channels = channels.where(lambda c: type(c).__name__ == filter["type"])
|
||||||
|
|
||||||
return users
|
return channels.order_by(lambda x: x.position)
|
||||||
|
@ -11,9 +11,9 @@
|
|||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"predocker-build": "npm run update-version",
|
"predocker-build": "npm run update-version",
|
||||||
"docker-build": "export VERSION=$npm_package_version; ng build; docker build -t kdb-web/kdb-web:$VERSION .",
|
"docker-build": "export VERSION=$npm_package_version; ng build; docker build -t sh-edraft.de/kdb-web:$VERSION .",
|
||||||
"docker-build-dev": "export VERSION=$npm_package_version; ng build --configuration development; docker build -t kdb-web/kdb-web:$VERSION .",
|
"docker-build-dev": "export VERSION=$npm_package_version; ng build --configuration development; docker build -t sh-edraft.de/kdb-web:$VERSION .",
|
||||||
"docker-build-stage": "export VERSION=$npm_package_version; ng build --configuration staging; docker build -t kdb-web/kdb-web:$VERSION ."
|
"docker-build-stage": "export VERSION=$npm_package_version; ng build --configuration staging; docker build -t sh-edraft.de/kdb-web:$VERSION ."
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -51,4 +51,4 @@
|
|||||||
"tslib": "^2.4.1",
|
"tslib": "^2.4.1",
|
||||||
"typescript": "~4.9.5"
|
"typescript": "~4.9.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user