Scalable and straightforward template for bots written in aiogram.
- Python 3.10
- Git
- Clone this repo via:
- HTTPS
git clone https://github.com/corruptmane/aiogram_template.git
- SSH
git clone [email protected]:corruptmane/aiogram_template.git
- HTTPS
- Move to the directory
cd aiogram_template
- If you want to use webhooks, you can create self-signed SSL certificate by executing
./gen_ssl
shell script. Before executing, runchmod +x gen_ssl
to allow executing on this script - Rename
env.example
to.env
and replace variables to your own
- Create a virtual environment:
python -m venv venv
- Activate a virtual environment:
- You use sh or bash or zsh:
source ./venv/bin/activate
or. ./venv/bin/activate
- You use fish:
source ./venv/bin/activate.fish
or. ./venv/bin/activate.fish
- You use csh:
source ./venv/bin/activate.csh
or. ./venv/bin/activate.csh
- You use sh or bash or zsh:
- Install requirements:
pip install -r requirements.txt
- Run your bot:
python -O bot.py
- Note: You need to have Docker and Docker Compose installed:
- Arch-based distro:
sudo pacman -S docker docker-compose
- Debian-based distro:
sudo apt install docker docker-compose
- Arch-based distro:
- Run command:
docker-compose up -d
- You need to add some secrets in your GitHub repository settings, such as:
- Docker Hub:
DOCKER_LOGIN
- Login of your Docker Hub accountDOCKER_PASSWORD
- Password of your Docker Hub account
- Server (SSH Credentials):
SERVER_HOST
- IP/URL of server to which you want to deploy your botSERVER_PORT
- Port opened for SSH connections on target serverSERVER_USER
- User to which we are connecting (such asroot
orubuntu
)SERVER_KEY
- SSH Private Key used to authenticate to target server (string)
- Docker Hub:
- Correctly set up your .env variable named
BOT_IMAGE_NAME
to something like this:BOT_IMAGE_NAME=your_docker_login/repository_name:latest
- On your server you need to have only
docker-compose.yml
and.env
files to successfully run your project - Test CI/CD runs manually in Actions section of repository.
After successful tests, you can edit
.github/workflows/cicd.yml
file to set up triggers when this pipeline would be triggered (e.g. push to master branch)