From 1f9d38148cecc6f2501b8d220f3ad3d284b008f4 Mon Sep 17 00:00:00 2001 From: bvn13 Date: Wed, 10 Jul 2024 23:52:19 +0300 Subject: [PATCH] prod tuning --- .gitignore | 2 +- .vscode/launch.json | 3 --- Dockerfile | 2 ++ config/newsmaker-prod.json | 28 ++++++++++++++++++++++++++ config/newsmaker.json | 40 ++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 38 ++++++++++-------------------------- requirements.txt | 3 ++- 7 files changed, 83 insertions(+), 33 deletions(-) create mode 100644 config/newsmaker-prod.json create mode 100644 config/newsmaker.json diff --git a/.gitignore b/.gitignore index 6bb173a..b52b463 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ local.env test/ newsmaker.session newsmaker.session-journal -newsmaker.session.bup +newsmaker-prod.session \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 73ea524..c59a1ce 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,9 +4,6 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ - - - { "name": "Python Debugger: main.py", "type": "debugpy", diff --git a/Dockerfile b/Dockerfile index cff7ba9..81bc608 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,8 @@ FROM python:3.10 RUN apt-get install libpq-dev -y +RUN apt-get install clang lib{jpeg-turbo,webp}-dev python{,-dev} zlib-dev + ADD requirements.txt requirements.txt RUN pip install -r requirements.txt diff --git a/config/newsmaker-prod.json b/config/newsmaker-prod.json new file mode 100644 index 0000000..027d881 --- /dev/null +++ b/config/newsmaker-prod.json @@ -0,0 +1,28 @@ +{ + "onMessage": { + "-1001491510225": [ + { + "filter": { + "type": "contain", + "value": "Школьный" + }, + "action": { + "type": "forward", + "chatId": -1001699667908 + } + } + ], + "-1001652154331": [ + { + "filter": { + "type": "contain", + "value": "Школьный" + }, + "action": { + "type": "forward", + "chatId": -1001699667908 + } + } + ] + } +} \ No newline at end of file diff --git a/config/newsmaker.json b/config/newsmaker.json new file mode 100644 index 0000000..f461791 --- /dev/null +++ b/config/newsmaker.json @@ -0,0 +1,40 @@ +{ + "onMessage": { + "-1001491510225": [ + { + "filter": { + "type": "contain", + "value": "Школьный" + }, + "action": { + "type": "forward", + "chatId": -1001699667908 + } + } + ], + "-1002182676107": [ + { + "filter": { + "type": "contain", + "value": "Школьный" + }, + "action": { + "type": "forward", + "chatId": -1002184916546 + } + } + ], + "-1001652154331": [ + { + "filter": { + "type": "contain", + "value": "Школьный" + }, + "action": { + "type": "forward", + "chatId": -1001699667908 + } + } + ] + } +} \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 2040ec2..050176f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,25 +1,16 @@ version: '3.3' -networks: - jedoist: - external: true - services: bot: # build: ./ - image: localhost:5001/jedoist:${APP_VERSION} + image: localhost:5001/tg-newsmaker:${APP_VERSION} environment: - - BOT_TOKEN=${BOT_TOKEN} - - VK_CLIENT_ID=${VK_CLIENT_ID} - - VK_SECRET_KEY=${VK_SECRET_KEY} - BOT_OWNER_ID=258985362 - - DB_HOST=jedoist-db - - DB_NAME=jedoist-db - - DB_USER=${DB_USER} - - DB_PASS=${DB_PASS} - - VOICES_PATH=${VOICES_PATH} - CONFIG_FILE=/mnt/config.json + - SESSION_FILE=/mnt/newsmaker.session + - TG_APP_ID=/run/secrets/tg_app_id + - TG_APP_HASH=/run/secrets/tg_app_hash restart: always depends_on: - bot-db @@ -27,18 +18,9 @@ services: - jedoist volumes: - ${CONFIG_FILE}:/mnt/config.json - - bot-db: - image: postgres:14 - container_name: jedoist-db - restart: always - environment: - POSTGRES_USER: ${DB_USER} - POSTGRES_PASSWORD: ${DB_PASS} - POSTGRES_DB: jedoist-db - networks: - - jedoist - volumes: - - ${DB_VOLUME}:/var/lib/postgresql/data - ports: - - 5432:5432 + - ${SESSION_FILE}:/mnt/newsmaker.session + secrets: + tg_app_id: + environment: "TG_APP_ID" + tg_app_hash: + environment: "TG_APP_HASH" diff --git a/requirements.txt b/requirements.txt index 5754427..b411b09 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ aiohttp==3.9.5 -telethon==1.36.0 \ No newline at end of file +telethon==1.36.0 +cryptg==0.4.0 \ No newline at end of file