services:
  # Discord Bot Service
  discord-bot:
    build:
      context: ./Bot
      dockerfile: Dockerfile
    container_name: uptime-kuma-discord-bot
    restart: unless-stopped
    environment:
      - DISCORD_TOKEN=${DISCORD_TOKEN}
      - GUILD_ID=${GUILD_ID}
      - CHANNEL_ID=${CHANNEL_ID}
      - CLIENT_ID=${CLIENT_ID}
      - UPDATE_TIME=${UPDATE_TIME:-30}
      - BACKEND_URL=http://web-backend:80/back-end.php
      - UPTIME_KUMA_URL=${UPTIME_KUMA_URL}
    depends_on:
      - web-backend
    networks:
      - uptime-kuma-network
    healthcheck:
      test: ["CMD", "node", "-e", "console.log('Bot is running')"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  # PHP Web Backend Service
  web-backend:
    build:
      context: ./Web
      dockerfile: Dockerfile
    container_name: uptime-kuma-web-backend
    restart: unless-stopped
    environment:
      - UPTIME_KUMA_URL=${UPTIME_KUMA_URL}
      - UPTIME_KUMA_API_KEY=${UPTIME_KUMA_API_KEY}
    ports:
      - "8080:80"
    networks:
      - uptime-kuma-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/back-end.php"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

networks:
  uptime-kuma-network:
    driver: bridge
