Prerequisites
Before you begin, ensure you have the following installed:- Docker Engine (20.10 or higher)
- Docker Compose (v2.0 or higher)
- Git (to clone the repository)
Quick start
The simplest way to get started:Configure the bot
Copy the example configuration file and add your bot token:Edit
config.toml and add your bot token and owner ID. See the Configuration page for details.Docker Compose configuration
Thedocker-compose.yml file defines two services:
App service
- Builds from the local Dockerfile
- Waits for the database service to start
- Connects to PostgreSQL using the
DATABASE_URLenvironment variable - Sets timezone to Europe/Berlin (adjust for your location)
Database service
- Uses the official PostgreSQL image
- Creates a database named
vbbautomatically - Exposes port 5432 for external access (optional)
- Persists data in a named volume
Dockerfile structure
The bot’s Dockerfile is minimal and efficient:- Uses Python 3.12 as the base image
- Copies all application files into the container
- Installs Python dependencies
- Sets the default command to run the bot
Managing the deployment
Start in detached mode
Run the bot in the background:View logs
Monitor the bot’s output:Stop the services
Stop all running containers:Restart the bot
Restart just the bot service:Rebuild after code changes
After making changes to the code, rebuild and restart:Environment variables
The Docker Compose configuration uses environment variables to configure the bot:| Variable | Description | Default Value |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | postgresql+asyncpg://postgres:postgres@db:5432/vbb |
TZ | Container timezone | Europe/Berlin |
docker-compose.yml file or create a .env file.
Production deployment
For production environments, consider these improvements:Use secrets for sensitive data
Instead of hardcoding passwords indocker-compose.yml, use Docker secrets or environment files:
Add restart policies
Ensure the bot restarts automatically:Configure resource limits
Limit memory and CPU usage:Set up database backups
Regularly backup the PostgreSQL data volume to prevent data loss.Troubleshooting
Container fails to start
Check the logs for errors:- Missing or invalid
config.tomlfile - Incorrect bot token
- Database connection problems
Database connection errors
Ensure the database container is healthy:Port conflicts
If port 5432 is already in use, modify the port mapping indocker-compose.yml:
Next steps
- Learn about all configuration options in Configuration
- Set up monitoring and logging for production
- Configure automated backups for the database