Compare commits

...

75 Commits

Author SHA1 Message Date
Egor Matveev
40907f9d07 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 1m16s
Deploy Dev / Push (pull_request) Successful in 21s
Deploy Dev / Deploy dev (pull_request) Successful in 10s
Deploy Prod / Build (pull_request) Successful in 5s
Deploy Prod / Push (pull_request) Successful in 10s
Deploy Prod / Deploy prod (pull_request) Successful in 11s
2025-09-15 01:33:01 +03:00
Egor Matveev
4c0bafa7cf fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
Deploy Prod / Build (pull_request) Successful in 5s
Deploy Prod / Push (pull_request) Successful in 9s
Deploy Prod / Deploy prod (pull_request) Successful in 6s
2025-06-12 12:28:21 +03:00
Egor Matveev
4daae8d2a0 fix
All checks were successful
Deploy Dev / Deploy dev (pull_request) Successful in 9s
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 9s
2025-06-12 02:45:41 +03:00
Egor Matveev
c25796c5e0 fix
All checks were successful
Deploy Dev / Deploy dev (pull_request) Successful in 10s
Deploy Dev / Build (pull_request) Successful in 4s
Deploy Dev / Push (pull_request) Successful in 9s
2025-06-12 02:39:08 +03:00
Egor Matveev
eed31426b2 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 10s
2025-06-12 02:35:03 +03:00
Egor Matveev
1822a24442 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
2025-06-12 02:25:17 +03:00
Egor Matveev
52ec293aaf fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 4s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-12 02:19:13 +03:00
Egor Matveev
627f044b08 fix
All checks were successful
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
Deploy Dev / Build (pull_request) Successful in 5s
2025-06-12 02:15:47 +03:00
Egor Matveev
bfb417f70b fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-12 02:09:47 +03:00
Egor Matveev
fb7716e8fb fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 17s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 9s
Deploy Prod / Build (pull_request) Successful in 5s
Deploy Prod / Push (pull_request) Successful in 9s
Deploy Prod / Deploy prod (pull_request) Successful in 7s
2025-06-12 01:10:55 +03:00
Egor Matveev
32377d93fe fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 6s
Deploy Dev / Push (pull_request) Successful in 11s
Deploy Dev / Deploy dev (pull_request) Successful in 14s
2025-06-12 00:54:10 +03:00
Egor Matveev
cab3256c10 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 11s
2025-06-10 02:04:24 +03:00
Egor Matveev
f7b2b7b7ee fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 6s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 10s
2025-06-10 02:02:10 +03:00
Egor Matveev
4baf1c94fa fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 6s
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 10s
2025-06-10 01:48:47 +03:00
Egor Matveev
fa0fc6f3bc fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 10s
2025-06-08 11:49:18 +03:00
Egor Matveev
9b89423d95 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 16s
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 10s
2025-06-08 11:38:06 +03:00
Egor Matveev
66eefeb324 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 9s
2025-06-08 11:05:13 +03:00
Egor Matveev
7ef998d635 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 9s
2025-06-08 11:01:53 +03:00
Egor Matveev
00c307fd1e fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 6s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 11s
2025-06-08 10:58:58 +03:00
Egor Matveev
8853542182 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 1m14s
Deploy Dev / Push (pull_request) Successful in 21s
Deploy Dev / Deploy dev (pull_request) Successful in 14s
2025-06-07 13:23:40 +03:00
Egor Matveev
67ab03227a fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
Deploy Prod / Build (pull_request) Successful in 4s
Deploy Prod / Push (pull_request) Successful in 10s
Deploy Prod / Deploy prod (pull_request) Successful in 7s
2025-06-04 21:07:43 +03:00
Egor Matveev
71521fdbb5 fix
All checks were successful
Deploy Prod / Deploy prod (pull_request) Successful in 7s
Deploy Prod / Build (pull_request) Successful in 5s
Deploy Prod / Push (pull_request) Successful in 10s
2025-06-04 03:07:02 +03:00
Egor Matveev
7e40a5e9f5 fix
All checks were successful
Deploy Prod / Build (pull_request) Successful in 5s
Deploy Prod / Push (pull_request) Successful in 9s
Deploy Prod / Deploy prod (pull_request) Successful in 5s
2025-06-04 02:55:58 +03:00
Egor Matveev
080f84477f fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 6s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 9s
Deploy Prod / Build (pull_request) Successful in 6s
Deploy Prod / Push (pull_request) Successful in 10s
Deploy Prod / Deploy prod (pull_request) Successful in 24s
2025-06-04 02:34:14 +03:00
Egor Matveev
965175be5a fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 27s
Deploy Dev / Deploy dev (pull_request) Successful in 10s
2025-06-03 22:53:25 +03:00
Egor Matveev
d1d23165fa fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 10s
Deploy Dev / Deploy dev (pull_request) Successful in 9s
2025-06-03 22:43:30 +03:00
Egor Matveev
21d1008abe fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
2025-06-02 00:19:08 +03:00
Egor Matveev
08fd556c2c fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 20:04:26 +03:00
Egor Matveev
81db99d44d fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
Deploy Dev / Push (pull_request) Successful in 8s
2025-06-01 19:58:18 +03:00
Egor Matveev
671f414e45 fix
All checks were successful
Deploy Dev / Deploy dev (pull_request) Successful in 8s
Deploy Dev / Build (pull_request) Successful in 4s
Deploy Dev / Push (pull_request) Successful in 8s
2025-06-01 19:54:59 +03:00
Egor Matveev
683320dc44 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 4s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 19:53:14 +03:00
Egor Matveev
0258778e5c Merge branch 'master' of https://gitea.sprinthub.ru/self/certupdater
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 5s
2025-06-01 19:50:32 +03:00
Egor Matveev
9778a5168b fix 2025-06-01 19:50:14 +03:00
713e8b58a3 Merge branch 'dev' into master
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 19:48:25 +03:00
Egor Matveev
62a57137d1 fix 2025-06-01 19:48:06 +03:00
f14bdcb7aa Merge pull request 'fix' (#21) from master into dev
Reviewed-on: #21
2025-06-01 19:45:01 +03:00
Egor Matveev
096506b9dd fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 18s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 19:44:31 +03:00
aa2057d8d6 Merge pull request 'fix' (#20) from master into dev
Reviewed-on: #20
2025-06-01 19:27:11 +03:00
Egor Matveev
510bf7f2e6 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 19:25:26 +03:00
3f94465db4 Merge pull request 'fix' (#19) from master into dev
Reviewed-on: #19
2025-06-01 19:24:35 +03:00
Egor Matveev
7abedce009 fix
Some checks failed
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Failing after 7s
2025-06-01 19:24:11 +03:00
07900cfe43 Merge pull request 'fix' (#18) from master into dev
Reviewed-on: #18
2025-06-01 15:12:48 +03:00
Egor Matveev
eaf5cbfa55 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 5s
2025-06-01 15:12:27 +03:00
5b572b2e66 Merge pull request 'fix' (#17) from master into dev
Reviewed-on: #17
2025-06-01 15:06:38 +03:00
Egor Matveev
224fb045e9 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
2025-06-01 15:06:22 +03:00
5efbd0e7fd Merge pull request 'fix' (#16) from master into dev
Reviewed-on: #16
2025-06-01 15:05:10 +03:00
Egor Matveev
ba8c2292a6 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
2025-06-01 15:04:46 +03:00
6e47ccb904 Merge pull request 'fix' (#15) from master into dev
Reviewed-on: #15
2025-06-01 15:02:52 +03:00
Egor Matveev
707bf34f8a fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
2025-06-01 15:02:30 +03:00
f99dd0c4b7 Merge pull request 'fix' (#14) from master into dev
Reviewed-on: #14
2025-06-01 14:58:29 +03:00
Egor Matveev
e00c2f7f71 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 14:57:54 +03:00
5f84b3e8df Merge pull request 'fix' (#13) from master into dev
Reviewed-on: #13
2025-06-01 14:51:00 +03:00
Egor Matveev
2abffabca8 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 14:50:44 +03:00
6ed10602ff Merge pull request 'fix' (#12) from master into dev
Reviewed-on: #12
2025-06-01 14:49:16 +03:00
Egor Matveev
b718b17f93 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 14:49:01 +03:00
d4af35ddbf Merge pull request 'fix' (#11) from master into dev
Reviewed-on: #11
2025-06-01 14:42:51 +03:00
Egor Matveev
8a64bec6fe fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 4s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 5s
2025-06-01 14:42:31 +03:00
c0eefdf3f0 Merge pull request 'fix' (#10) from master into dev
Reviewed-on: #10
2025-06-01 14:01:58 +03:00
Egor Matveev
0f4e509639 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 8s
Deploy Dev / Deploy dev (pull_request) Successful in 6s
2025-06-01 14:01:42 +03:00
d4ef8b6b7c Merge pull request 'fix' (#9) from master into dev
Reviewed-on: #9
2025-06-01 13:59:48 +03:00
Egor Matveev
29e4912a95 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 5s
Deploy Dev / Push (pull_request) Successful in 13s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 13:59:17 +03:00
11516b1a6e Merge pull request 'fix' (#8) from master into dev
Reviewed-on: #8
2025-06-01 01:13:10 +03:00
Egor Matveev
cc0c578cdc fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 24s
Deploy Dev / Push (pull_request) Successful in 11s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 01:12:52 +03:00
90d5d957e0 Merge pull request 'fix' (#7) from master into dev
Reviewed-on: #7
2025-06-01 01:10:42 +03:00
Egor Matveev
8e193e2e87 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 23s
Deploy Dev / Push (pull_request) Successful in 15s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-06-01 01:10:28 +03:00
5c1a8a3a5e Merge pull request 'fix' (#6) from master into dev
Reviewed-on: #6
2025-06-01 01:07:52 +03:00
Egor Matveev
317b371977 fix
Some checks failed
Deploy Dev / Build (pull_request) Failing after 27s
Deploy Dev / Push (pull_request) Has been skipped
Deploy Dev / Deploy dev (pull_request) Has been skipped
2025-06-01 01:07:20 +03:00
f8d5acb4a0 Merge pull request 'fix' (#5) from master into dev
Reviewed-on: #5
2025-06-01 01:05:29 +03:00
Egor Matveev
580eb94ef7 fix
Some checks failed
Deploy Dev / Build (pull_request) Failing after 6s
Deploy Dev / Push (pull_request) Has been skipped
Deploy Dev / Deploy dev (pull_request) Has been skipped
2025-06-01 01:05:00 +03:00
9ead345f05 Merge pull request 'fix' (#4) from master into dev
Reviewed-on: #4
2025-05-31 13:50:13 +03:00
Egor Matveev
17858ba868 fix
Some checks failed
Deploy Dev / Build (pull_request) Failing after 6s
Deploy Dev / Push (pull_request) Has been skipped
Deploy Dev / Deploy dev (pull_request) Has been skipped
2025-05-31 13:49:54 +03:00
f0c1f1a935 Merge pull request 'fix' (#3) from master into dev
Reviewed-on: #3
2025-05-31 13:48:48 +03:00
Egor Matveev
fed8955dd3 fix
Some checks failed
Deploy Dev / Build (pull_request) Failing after 7s
Deploy Dev / Push (pull_request) Has been skipped
Deploy Dev / Deploy dev (pull_request) Has been skipped
2025-05-31 13:48:29 +03:00
72500ab48d Merge pull request 'fix' (#2) from master into dev
Reviewed-on: #2
2025-05-31 13:44:02 +03:00
Egor Matveev
ad830c6ba6 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 44s
Deploy Dev / Push (pull_request) Successful in 17s
Deploy Dev / Deploy dev (pull_request) Successful in 17s
2025-05-31 13:43:40 +03:00
12 changed files with 182 additions and 180 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -6,15 +6,22 @@ services:
image: mathwave/sprint-repo:certupdater image: mathwave/sprint-repo:certupdater
command: worker command: worker
environment: environment:
MONGO_HOST: "mongo.develop.sprinthub.ru" MINIO_SECRET_KEY: $MINIO_SECRET_KEY_DEV
MONGO_PASSWORD: $MONGO_PASSWORD_DEV MONGO_PASSWORD: $MONGO_PASSWORD_DEV
STAGE: "development" STAGE: "development"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks: networks:
- configurator - configurator
- queues-development
- minio-development
- mongo-development
deploy: deploy:
mode: replicated mode: replicated
restart_policy: restart_policy:
condition: any condition: any
placement:
constraints: [node.labels.stage == development]
update_config: update_config:
parallelism: 1 parallelism: 1
order: start-first order: start-first
@@ -22,3 +29,9 @@ services:
networks: networks:
configurator: configurator:
external: true external: true
queues-development:
external: true
minio-development:
external: true
mongo-development:
external: true

View File

@@ -2,44 +2,36 @@ version: "3.4"
services: services:
worker: certupdater:
image: mathwave/sprint-repo:pizda-bot image: mathwave/sprint-repo:certupdater
command: worker command: worker
environment: environment:
MONGO_HOST: "mongo.sprinthub.ru" MINIO_SECRET_KEY: $MINIO_SECRET_KEY_PROD
MONGO_PASSWORD: $MONGO_PASSWORD_PROD MONGO_PASSWORD: $MONGO_PASSWORD_PROD
STAGE: "production" STAGE: "production"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks: networks:
- queues
- configurator - configurator
- queues
- minio
- mongo
deploy: deploy:
mode: replicated mode: replicated
restart_policy: restart_policy:
condition: any condition: any
update_config: placement:
parallelism: 1 constraints: [node.labels.stage == production]
order: start-first
pizda-bot-nginx:
image: mathwave/sprint-repo:pizda-bot
command: api
environment:
MONGO_HOST: "mongo.sprinthub.ru"
MONGO_PASSWORD: $MONGO_PASSWORD_PROD
networks:
- common-infra-nginx
deploy:
mode: replicated
restart_policy:
condition: any
update_config: update_config:
parallelism: 1 parallelism: 1
order: start-first order: start-first
networks: networks:
common-infra-nginx: configurator:
external: true external: true
queues: queues:
external: true external: true
configurator: minio:
external: true
mongo:
external: true external: true

View File

@@ -18,14 +18,14 @@ jobs:
with: with:
ref: dev ref: dev
- name: build - name: build
run: docker build -t mathwave/sprint-repo:pizda-bot . run: docker build -t mathwave/sprint-repo:certupdater .
push: push:
name: Push name: Push
runs-on: [ dev ] runs-on: [ dev ]
needs: build needs: build
steps: steps:
- name: push - name: push
run: docker push mathwave/sprint-repo:pizda-bot run: docker push mathwave/sprint-repo:certupdater
deploy-dev: deploy-dev:
name: Deploy dev name: Deploy dev
runs-on: [prod] runs-on: [prod]
@@ -40,4 +40,5 @@ jobs:
- name: deploy - name: deploy
env: env:
MONGO_PASSWORD_DEV: ${{ secrets.MONGO_PASSWORD_DEV }} MONGO_PASSWORD_DEV: ${{ secrets.MONGO_PASSWORD_DEV }}
run: docker stack deploy --with-registry-auth -c ./.deploy/deploy-dev.yaml pizda-bot-development MINIO_SECRET_KEY_DEV: ${{ secrets.MINIO_SECRET_KEY_DEV }}
run: docker stack deploy --with-registry-auth -c ./.deploy/deploy-dev.yaml certupdater-development

View File

@@ -18,14 +18,14 @@ jobs:
with: with:
ref: prod ref: prod
- name: build - name: build
run: docker build -t mathwave/sprint-repo:pizda-bot . run: docker build -t mathwave/sprint-repo:certupdater .
push: push:
name: Push name: Push
runs-on: [ dev ] runs-on: [ dev ]
needs: build needs: build
steps: steps:
- name: push - name: push
run: docker push mathwave/sprint-repo:pizda-bot run: docker push mathwave/sprint-repo:certupdater
deploy-prod: deploy-prod:
name: Deploy prod name: Deploy prod
runs-on: [prod] runs-on: [prod]
@@ -40,4 +40,5 @@ jobs:
- name: deploy - name: deploy
env: env:
MONGO_PASSWORD_PROD: ${{ secrets.MONGO_PASSWORD_PROD }} MONGO_PASSWORD_PROD: ${{ secrets.MONGO_PASSWORD_PROD }}
run: docker stack deploy --with-registry-auth -c ./.deploy/deploy-prod.yaml pizda-bot MINIO_SECRET_KEY_PROD: ${{ secrets.MINIO_SECRET_KEY_PROD }}
run: docker stack deploy --with-registry-auth -c ./.deploy/deploy-prod.yaml certupdater

View File

@@ -2,8 +2,14 @@ FROM docker:dind
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 py3-pip && ln -sf python3 /usr/bin/python RUN apk add --update --no-cache python3 py3-pip && ln -sf python3 /usr/bin/python
RUN mkdir /code
WORKDIR /code
RUN python3 -m venv venv RUN python3 -m venv venv
RUN venv/bin/python3 -m ensurepip RUN venv/bin/python3 -m ensurepip
RUN venv/bin/pip3 install --no-cache --upgrade pip setuptools RUN venv/bin/pip3 install --no-cache --upgrade pip setuptools
COPY requirements.txt requirements.txt
RUN venv/bin/pip3 install -r requirements.txt
COPY . .
ENTRYPOINT [ "venv/bin/python3", "main.py" ] ENTRYPOINT [ "venv/bin/python3", "main.py" ]

View File

@@ -1,7 +1,7 @@
import os import os
from minio import Minio from minio import Minio
MINIO_HOST = os.getenv("MINIO_HOST", "localhost") + ":9000" MINIO_HOST = "minio:9000"
MINIO_ACCESS_KEY = os.getenv("MINIO_ACCESS_KEY", "serviceminioadmin") MINIO_ACCESS_KEY = os.getenv("MINIO_ACCESS_KEY", "serviceminioadmin")
MINIO_SECRET_KEY = os.getenv("MINIO_SECRET_KEY", "minioadmin") MINIO_SECRET_KEY = os.getenv("MINIO_SECRET_KEY", "minioadmin")

View File

@@ -1,88 +0,0 @@
import json
import os
import urllib.parse
from threading import Thread
from time import sleep
from requests import get
class ConfiguratorClient:
def __init__(self, app_name: str, stage: str, need_poll: bool = True):
self.app_name = app_name
self.stage = stage
self.endpoint = 'http://configurator/'
self.fetch_url = urllib.parse.urljoin(self.endpoint, '/api/v1/fetch')
self.config_storage = {}
self.experiment_storage = {}
self.staff_storage = {}
self.poll_data()
if need_poll:
self.poll_data_in_thread()
def poll_data_in_thread(self):
def inner():
while True:
sleep(30)
self.fetch()
Thread(target=inner, daemon=True).start()
def poll_data(self):
self.fetch(with_exception=True)
def request_with_retries(self, url, params, with_exception=False, retries_count=3):
exception_to_throw = None
for _ in range(retries_count):
try:
response = get(
url,
params=params
)
if response.status_code == 200:
return response.json()
print(f'Failed to request {url}, status_code={response.status_code}')
exception_to_throw = Exception('Not 200 status')
except Exception as exc:
print(exc)
exception_to_throw = exc
sleep(1)
print(f'Failed fetching with retries: {url}, {params}')
if with_exception:
raise exception_to_throw
def fetch(self, with_exception=False):
if self.stage == 'local':
local_platform = json.loads(open('local_platform.json', 'r').read())
self.config_storage = local_platform['configs']
self.experiment_storage = local_platform['experiments']
self.staff_storage = {
key: set(value)
for key, value in local_platform['platform_staff'].items()
}
return
response_data = self.request_with_retries(self.fetch_url, {
'project': self.app_name,
'stage': self.stage,
}, with_exception)
self.config_storage = response_data['configs']
self.experiment_storage = response_data['experiments']
self.staff_storage = {
key: set(value)
for key, value in response_data['platform_staff'].items()
}
def is_staff(self, **kwargs):
for key, value in kwargs.items():
if value in self.staff_storage[key]:
return True
return False
def get_config(self, name):
return self.config_storage[name]
def get_experiment(self, name):
return self.experiment_storage[name]
configurator = ConfiguratorClient("certupdater", os.getenv("STAGE"))

142
main.py
View File

@@ -1,7 +1,10 @@
import datetime import datetime
import io
import os
import subprocess import subprocess
import time import time
from configurator import configurator
from requests import get, post
from mongo import mongo from mongo import mongo
from blob import minio from blob import minio
@@ -12,33 +15,136 @@ class Response:
err: str err: str
def send_notification(text: str):
post(
"http://queues:1239/api/v1/put",
headers={"queue": "botalka_mailbox"},
json={
"payload": {
"project": "notifications-bot",
"name": "telegram-bot",
"body": {
"text": text,
"chat_id": 84367486,
},
},
"seconds_to_execute": 1,
"delay": None,
},
)
def call(command: str) -> Response: def call(command: str) -> Response:
p = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) p = subprocess.Popen(
command, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True
)
resp = p.wait() resp = p.wait()
response = Response() response = Response()
response.code = resp response.code = resp
response.out, response.err = p.stdout.read().decode('utf-8'), p.stderr.read().decode('utf-8') response.out, response.err = p.stdout.read().decode(
"utf-8"
), p.stderr.read().decode("utf-8")
return response return response
def get_hosts() -> list[str]: def get_hosts() -> list[str]:
return list(set(configurator.get_config("hosts") + ["platform.chocomarsh.com"])) response = get(
f"http://configurator/api/v1/fetch?project=certupdater&stage={os.getenv("STAGE")}"
).json()
hosts = response["configs"]["hosts"]
return list(hosts)
def update_host(host: str): def update_host(host: str) -> str | None:
gen_cert = call(f"docker exec $(docker ps -q -f name=infra_nginx) certbot --nginx --email emmtvv@gmail.com --agree-tos -d \"{host}\"") if os.getenv("STAGE") == "development":
container_id_run = call("echo $(docker ps -q -f name=infra-development_nginx)")
else:
container_id_run = call("echo $(docker ps -q -f name=infra_nginx)")
if container_id_run.code != 0:
return container_id_run.err
container_name = container_id_run.out.strip()
if not container_name:
return "no nginx container"
gen_command = f'docker exec {container_name} certbot --nginx --email emmtvv@gmail.com --agree-tos --non-interactive -d "{host}"'
gen_cert = call(gen_command)
if gen_cert.code != 0: if gen_cert.code != 0:
print("failed generating certificate") log = call(
return f"docker exec {container_name} cat /var/log/letsencrypt/letsencrypt.log"
).out
return f"failed generating certificate: {log}"
fullchain_command = call(
f"docker exec {container_name} cat /etc/letsencrypt/live/{host}/fullchain.pem"
)
if fullchain_command.code != 0:
return f"failed getting fullchain: {fullchain_command.err}"
privkey_command = call(
f"docker exec {container_name} cat /etc/letsencrypt/live/{host}/privkey.pem"
)
if privkey_command.code != 0:
return f"failed getting fullchain: {privkey_command.err}"
fullchain = fullchain_command.out.encode("utf-8")
privkey = privkey_command.out.encode("utf-8")
minio.put_object(
"certupdater",
f"certificates/{host}/fullchain.pem",
io.BytesIO(fullchain),
len(fullchain),
)
minio.put_object(
"certupdater",
f"certificates/{host}/privkey.pem",
io.BytesIO(privkey),
len(privkey),
)
return None
while True: if __name__ == "__main__":
now = datetime.datetime.now() while True:
mongo_hosts = mongo.hosts now = datetime.datetime.now()
for host in get_hosts(): mongo_hosts = mongo.hosts
if now() + datetime.timedelta(days=14) > mongo_hosts[host]["expire_time"]: hosts = get_hosts()
update_host(host) print(f"got hosts {hosts}")
print(f"Host {host} updated") updated = False
minio.put_object("certupdater", "nginx.conf", ) for host in hosts:
time.sleep(5 * 60) if (
now + datetime.timedelta(days=14)
> mongo_hosts.get(
host, {"expire_time": datetime.datetime.fromtimestamp(1)}
)["expire_time"]
):
success = update_host(host)
if success:
print(success)
send_notification(
f"host {host} was not updated with an error: {success}"
)
else:
mongo.update_date(host)
updated = True
send_notification(f"host {host} updated")
else:
print(f"Host {host} does not need to be updated")
if updated:
if os.getenv("STAGE") == "development":
container_id_run = call(
"echo $(docker ps -q -f name=infra-development_nginx)"
)
else:
container_id_run = call("echo $(docker ps -q -f name=infra_nginx)")
print(container_id_run.code, container_id_run.out, container_id_run.err)
command = f"docker exec {container_id_run.out.strip()} ./refre.sh"
print(command)
restart = call(command)
print(restart.code, restart.out, restart.err)
send_notification(f"Balancer for {os.getenv("STAGE")} was restarted")
time.sleep(30)

View File

@@ -4,12 +4,11 @@ import os
MONGO_USER = os.getenv("MONGO_USER", "mongo") MONGO_USER = os.getenv("MONGO_USER", "mongo")
MONGO_PASSWORD = os.getenv("MONGO_PASSWORD", "password") MONGO_PASSWORD = os.getenv("MONGO_PASSWORD", "password")
MONGO_HOST = os.getenv("MONGO_HOST", "localhost")
class Mongo: class Mongo:
def __init__(self): def __init__(self):
url = f"mongodb://{MONGO_USER}:{MONGO_PASSWORD}@{MONGO_HOST}:27017/" url = f"mongodb://{MONGO_USER}:{MONGO_PASSWORD}@mongo:27017/"
self.client: pymongo.MongoClient = pymongo.MongoClient(url) self.client: pymongo.MongoClient = pymongo.MongoClient(url)
self.database = self.client.get_database("certupdater") self.database = self.client.get_database("certupdater")
self.hosts_collection.create_index([ self.hosts_collection.create_index([

14
requirements.txt Normal file
View File

@@ -0,0 +1,14 @@
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
certifi==2025.4.26
cffi==1.17.1
charset-normalizer==3.4.2
dnspython==2.7.0
idna==3.10
minio==7.2.15
pycparser==2.22
pycryptodome==3.23.0
pymongo==4.13.0
requests==2.32.3
typing_extensions==4.13.2
urllib3==2.4.0

View File

@@ -1,42 +0,0 @@
from cachetools import TTLCache
import os
from utils.mongo import mongo
CACHE_SIZE = int(os.getenv("CACHE_SIZE", 1000))
CACHE_TTL = int(os.getenv("CACHE_TTL", 3600))
cache = TTLCache(CACHE_SIZE, CACHE_TTL)
def get_chat_info(chat_id: int) -> dict:
cached_info = cache.get(chat_id)
if cached_info is not None:
return cached_info
mongo_info = mongo.chats_collection.find_one({"chat_id": chat_id})
if mongo_info is not None:
cache[chat_id] = mongo_info
return mongo_info
chat_info = {"chat_id": chat_id, "state": "default", "probability": 100}
mongo.chats_collection.insert_one(chat_info)
cache[chat_id] = chat_info
return chat_info
def set_values(chat_id: int, **values):
cached_info = cache.get(chat_id)
if cached_info is None:
mongo_info = mongo.chats_collection.find_one({"chat_id": chat_id})
if mongo_info is None:
chat_info = {"chat_id": chat_id, "state": "default", "probability": 100}
chat_info.update(values)
mongo.chats_collection.insert_one(chat_info)
cache[chat_id] = chat_info
else:
mongo.chats_collection.update_one({"chat_id": chat_id}, {"$set": values})
mongo_info = dict(mongo_info)
mongo_info.update(values)
cache[chat_id] = mongo_info
else:
cached_info.update(values)
mongo.chats_collection.update_one({"chat_id": chat_id}, {"$set": values})