services:
  bot:
    build: .
    restart: unless-stopped
    env_file:
      - .env
    environment:
      DB_HOST: db
      DB_PORT: 3306
    depends_on:
      db:
        condition: service_healthy

  db:
    image: mariadb:11.7
    restart: unless-stopped
    environment:
      MARIADB_DATABASE: ${DB_NAME:-telegabot}
      MARIADB_USER: ${DB_USER:-telegabot}
      MARIADB_PASSWORD: ${DB_PASSWORD:-telegabot_password}
      MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-root_password}
    volumes:
      - mariadb_data:/var/lib/mysql
    healthcheck:
      test: ["CMD-SHELL", "mariadb-admin ping -h localhost -p$$MARIADB_ROOT_PASSWORD --silent"]
      interval: 10s
      timeout: 5s
      retries: 10

volumes:
  mariadb_data:
