🤖 Lightweight, simple, but powerful template for scalable Aiogram bots.
Click for detailed description
-
Poetry: As main dependency and package manager.
-
Webhook Support: Easily configure and deploy bots with webhooks.
-
Nginx Integration: Serving your bot over HTTPS and manage webhooks.
-
Logging & Monitoring: Logging, debugging and monitoring.
-
Dockerized: Fully Dockerized.
-
Postgres: As main database storage.
-
Alembic: Migration tool.
-
Redis: As main cache storage
-
Localization: Translatable support for different languages with.
git clone https://github.com/serdukow/easy-aiogram-bot-template.git
cd easy-aiogram-bot-template
Click for Webhook installation details
Ensure you have your own domain and any VPS.
To set up the webhook, follow these steps:
- Set your domain in the
.env
file under theNGINX_HOST
variable.
NGINX_HOST=your-domain.com
- Build and start the Docker containers using the .env file:
docker compose --env-file .env build
docker compose run --rm -d -p 80:80 nginx
- Verify it by using curl:
curl http://your-domain.com
If you receive an HTTP 301 redirect, everything is working fine.
- Simulate certificate issuance:
docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ --dry-run -d your-domain.com
If the dry run is successful, you should see a appropriate message
- Issue the SSL certificate:
docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d your-domain.com
- Stop the containers:
docker compose kill && docker compose down
- Update docker-compose.yml for production:
volumes:
# - ./nginx/initial:/etc/nginx/templates/:ro
- ./nginx/templates:/etc/nginx/templates/:ro
- Finally verify and restart with the final setup, do not forget to set this vars in
.env
:
USE_WEBHOOK=True
WEBHOOK_HOST='https://your-domain.com'
then run test:
poetry run pytest tests/test_webhook.py
finally compose
docker compose up --build
Renewing SSL Certificate: After 3 months, you’ll need to renew the SSL certificate. To do so, run:
docker compose up
dockercompose run --rm certbot renew
Click for Polling installation details
To start bot without webhook, just fill .env
with your keys, then verify it by run this command in terminal:
poetry run pytest tests/test_polling.py
then remove services nginx, certbot from docker-compose.yml
and finally:
docker compose up --build
- Tests
- Basic
- Versions
- React Webapp integration
- Database
- Alembic
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.