version: '3.8' services: telegram-bot: build: context: . dockerfile: Dockerfile.bot container_name: telegram-bot restart: unless-stopped expose: - "8000" 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:-8000} # 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:-/app/database/tg-bot-database.db} volumes: - ./database:/app/database:rw - ./logs:/app/logs:rw - ./.env:/app/.env:ro networks: - bot-internal depends_on: - prometheus - grafana healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s deploy: resources: limits: memory: 512M cpus: '0.5' reservations: memory: 256M cpus: '0.25' prometheus: image: prom/prometheus:latest container_name: prometheus expose: - "9090" volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus_data:/prometheus 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=200h' - '--web.enable-lifecycle' restart: unless-stopped networks: - bot-internal healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9090/-/healthy"] interval: 30s timeout: 10s retries: 3 deploy: resources: limits: memory: 256M cpus: '0.25' grafana: image: grafana/grafana:latest container_name: grafana ports: - "3000:3000" # Grafana доступна извне environment: - GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin} - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin} - GF_USERS_ALLOW_SIGN_UP=false - GF_SERVER_ROOT_URL=http://localhost:3000 volumes: - grafana_data:/var/lib/grafana - ./grafana/dashboards:/etc/grafana/provisioning/dashboards:ro - ./grafana/datasources:/etc/grafana/provisioning/datasources:ro restart: unless-stopped networks: - bot-internal depends_on: - prometheus healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:3000/api/health || exit 1"] interval: 30s timeout: 10s retries: 3 deploy: resources: limits: memory: 256M cpus: '0.25' volumes: prometheus_data: driver: local grafana_data: driver: local networks: bot-internal: driver: bridge ipam: config: - subnet: 172.20.0.0/16