Giter Club home page Giter Club logo

mathdailybot's Introduction

Math Daily

This is a Telegram bot with a base of math problems with three different topics and a difficulty setting from 0 to 4 (very easy to insane). You ask the bot to send a problem by clicking the "Give task" button.

The possible commands are:

  1. Give task. Before recieving a task there is an option to choose the subject of the problem (Set theory, Logic and Combinatorics)
  2. Give a hint (there is one hint for each problem)
  3. Give a solution

It is made sure that you don't get the same probem twice.

Docker

Система состоит из трех компонентов: PostgreSQL, бекенда бота и nginx. При переходе по адресу 127.0.0.1:1234/images/gopher.png вы увидете картинку, которую отдает nginx.

Образ с бекендом бота залит в публичный репозиторий romanovsavelij/math-bot-daily-backend.

Перед запуском надо попросить у @romanovsavelij файл key.py с ключами и добавить его в папку src/ проект. Запускать так:

docker-compose up

k8s

Запуск k8s через minikube

minikube start

Сборка контейнера бота

docker build -t math-bot-backend .

Пробросим локально собранный образ в minikube

minikube image load math-bot-backend

Создаем deployment базы с volume под нее

kubectl create -f kube/postgres.yaml

Создаем deployment бота

kubectl create -f kube/app.yaml

Открываем доступ изве через LoadBalancer

kubectl expose deployment math-bot-backend -- type=LoadBalancer ---port=8080

Пробросим порт для nginx

kubectl port-forward math-bot-backend 1234:80

Теперь можем посмотреть состояние наше кластера, все должно быть успешно запущено

minikube dashboard

По адресу http://localhost:1234/images/gopher.png видим локально гофера, значит все запустилось.

ansible

В папке ansible лежат все настройки для ansible. В inventory.hosts обьявлены хосты, куда мы будем деплоить сервис, в deploy_playbook.yml плейбук для деплоя. В server/Dockerfile лежит исходник образа, который запускается на чистой машине, где выкачиваются все нужные зависимости и поднимается сервис.

Деплоить так:

ansible-playbook ansible/deploy_playbook.yml -i ansible/inventory.hosts

jenkins

По коммиту запускается jenkins pipeline, который проверяет код и делает деплой на голую продакш машину.

А запускается по коммиту, прогоняет тесты отдельном контейнере через pytest, отбрасывает результаты тестов в allure, прогоняет анализ кода в Sonar и в конце делает деплой сервиса на продакш хост.

Нужные для jenkins скрипты лежат тут.
Пайплайн можно настроить тут.
Sonar
Allure

mathdailybot's People

Contributors

gefedya avatar romanovsavelij avatar

Watchers

 avatar  avatar

Forkers

gefedya

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.