This document explains how to run TG AntiSpam Bot using Docker and Docker Compose.
It is written to be fully usable without Make. If you prefer shortcuts, see the Optional: Make section at the end.
Install:
- Docker
- Docker Compose v2
Check installation:
docker --version
docker compose version- Clone the repository:
git clone <repository-url>
cd TGAntiSpamBot- Create environment file:
cp .env.example .envEdit .env and set at least:
APP_BOT_TOKEN=your_bot_token_here
APP_MAIN_ADMIN_ID=your_telegram_user_id- Build the image:
docker compose build- Start the container:
docker compose up -d- Watch logs:
docker compose logs -fThe bot will:
- build and start as a container
- run database migrations automatically at startup
- start in polling mode by default (if
APP_BOT_MODE=polling)
The project uses a single service:
services:
app:
build: .
volumes:
- ./database:/app/database
- ./logs:/app/logs
restart: unless-stopped./database→ SQLite database persistence./logs→ application logs (if enabled)
This means:
- restarting the container does not reset the database
- logs survive container restarts
No public URL required.
APP_BOT_MODE=pollingGood for:
- local development
- simple VPS setups
- quick testing
Webhook mode requires:
- public HTTPS URL
- exposed port (default:
8000)
Environment variables:
APP_BOT_MODE=webhook
APP_WEBHOOK_URL=https://your-domain.com
APP_RUN_PORT=8000You must expose the port:
services:
app:
ports:
- "8000:8000"
⚠️ Telegram requires HTTPS for webhooks ngrok, Cloudflare Tunnel, or a real domain are suitable.
docker compose builddocker compose build --no-cachedocker compose up -ddocker compose updocker compose stopdocker compose down --remove-orphansdocker compose logs -fdocker compose restartSee container logs:
docker compose logs -fIf APP_WRITE_TO_FILE=true, logs are also written to:
./logs/app.log
This repository includes a Makefile that wraps the same Docker Compose commands.
Example:
make run
make logsIf you like shortcuts - use it. If you prefer explicit Docker commands - ignore it completely.
📄 Make reference: docs/MAKE.md