Initial commit: Add infrastructure and bot project
This commit is contained in:
145
docker-compose.yml
Normal file
145
docker-compose.yml
Normal file
@@ -0,0 +1,145 @@
|
||||
|
||||
services:
|
||||
# Prometheus Monitoring
|
||||
prometheus:
|
||||
image: prom/prometheus:latest
|
||||
container_name: bots_prometheus
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--storage.tsdb.path=/prometheus'
|
||||
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
||||
- '--web.console.templates=/etc/prometheus/consoles'
|
||||
- '--storage.tsdb.retention.time=${PROMETHEUS_RETENTION_DAYS:-30}d'
|
||||
- '--web.enable-lifecycle'
|
||||
ports:
|
||||
- "9090:9090"
|
||||
volumes:
|
||||
- ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- prometheus_data:/prometheus
|
||||
networks:
|
||||
- bots_network
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9090/-/healthy"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
# Grafana Dashboard
|
||||
grafana:
|
||||
image: grafana/grafana:latest
|
||||
container_name: bots_grafana
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin}
|
||||
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
|
||||
- GF_USERS_ALLOW_SIGN_UP=false
|
||||
- GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- grafana_data:/var/lib/grafana
|
||||
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
networks:
|
||||
- bots_network
|
||||
depends_on:
|
||||
- prometheus
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -f http://localhost:3000/api/health || exit 1"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
# Server Monitoring Service
|
||||
server_monitor:
|
||||
build: .
|
||||
container_name: bots_server_monitor
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- TELEGRAM_BOT_TOKEN=${TELEGRAM_MONITORING_BOT_TOKEN}
|
||||
- GROUP_FOR_LOGS=${GROUP_MONITORING_FOR_LOGS}
|
||||
- IMPORTANT_LOGS=${IMPORTANT_MONITORING_LOGS}
|
||||
- THRESHOLD=${THRESHOLD:-80.0}
|
||||
- RECOVERY_THRESHOLD=${RECOVERY_THRESHOLD:-75.0}
|
||||
volumes:
|
||||
- /proc:/host/proc:ro
|
||||
- /sys:/host/sys:ro
|
||||
- /var/run:/host/var/run:ro
|
||||
networks:
|
||||
- bots_network
|
||||
depends_on:
|
||||
- prometheus
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "ps aux | grep python | grep server_monitor || exit 1"]
|
||||
interval: 60s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
# Telegram Helper Bot
|
||||
telegram-bot:
|
||||
build:
|
||||
context: ./bots/telegram-helper-bot
|
||||
dockerfile: Dockerfile.bot
|
||||
container_name: bots_telegram_bot
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
- PYTHONPATH=/app
|
||||
- DOCKER_CONTAINER=true
|
||||
- LOG_LEVEL=${LOG_LEVEL:-INFO}
|
||||
- LOG_RETENTION_DAYS=${LOG_RETENTION_DAYS:-30}
|
||||
- METRICS_HOST=${METRICS_HOST:-0.0.0.0}
|
||||
- METRICS_PORT=${METRICS_PORT:-8080}
|
||||
# Telegram settings
|
||||
- TELEGRAM_BOT_TOKEN=${BOT_TOKEN}
|
||||
- TELEGRAM_LISTEN_BOT_TOKEN=${LISTEN_BOT_TOKEN}
|
||||
- TELEGRAM_TEST_BOT_TOKEN=${TEST_BOT_TOKEN}
|
||||
- TELEGRAM_PREVIEW_LINK=${PREVIEW_LINK:-false}
|
||||
- TELEGRAM_MAIN_PUBLIC=${MAIN_PUBLIC}
|
||||
- TELEGRAM_GROUP_FOR_POSTS=${GROUP_FOR_POSTS}
|
||||
- TELEGRAM_GROUP_FOR_MESSAGE=${GROUP_FOR_MESSAGE}
|
||||
- TELEGRAM_GROUP_FOR_LOGS=${GROUP_FOR_LOGS}
|
||||
- TELEGRAM_IMPORTANT_LOGS=${IMPORTANT_LOGS}
|
||||
- TELEGRAM_ARCHIVE=${ARCHIVE}
|
||||
- TELEGRAM_TEST_GROUP=${TEST_GROUP}
|
||||
# Bot settings
|
||||
- SETTINGS_LOGS=${LOGS:-false}
|
||||
- SETTINGS_TEST=${TEST:-false}
|
||||
# Database
|
||||
- DATABASE_PATH=${DATABASE_PATH:-database/tg-bot-database.db}
|
||||
volumes:
|
||||
- ./bots/telegram-helper-bot/database:/app/database:rw
|
||||
- ./bots/telegram-helper-bot/logs:/app/logs:rw
|
||||
- ./bots/telegram-helper-bot/.env:/app/.env:ro
|
||||
networks:
|
||||
- bots_network
|
||||
depends_on:
|
||||
- prometheus
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 512M
|
||||
cpus: '0.5'
|
||||
reservations:
|
||||
memory: 256M
|
||||
cpus: '0.25'
|
||||
|
||||
volumes:
|
||||
prometheus_data:
|
||||
driver: local
|
||||
grafana_data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
bots_network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 192.168.100.0/24
|
||||
Reference in New Issue
Block a user