version: "3.8"

services:
  web:
    container_name: mc-web-patata
    image: nginx
    volumes:
      - ./web:/usr/share/nginx/html
    ports:
      - "8080:80"
  mc:
    image: itzg/minecraft-server
    tty: true
    stdin_open: true
    depends_on:
      - web
    ports:
      - "25565:25565"
      - "24454:24454/udp"
      - "19565:19565"
    restart: unless-stopped
    container_name: mc-forge-patata
    environment:
      OVERRIDE_SERVER_PROPERTIES: "TRUE"
      EULA: "TRUE"
      PACKWIZ_URL: http://patatapack.oier.ovh/pack.toml
      TYPE: FORGE
      VERSION: 1.20.1
      FORGE_VERSION: 47.2.0
      MEMORY: 30G
      MOTD: "§l§cPatataPack§r"
      ONLINE_MODE: "FALSE"
      ALLOW_FLIGHT: "TRUE"
      RCON_PASSWORD: "${RCON_PASSWORD}"
      BROADCAST_RCON_TO_OPS: "FALSE"
      OPS: |
        Bailongo
        Amimi
        Mestrefox
      EXISTING_OPS_FILE: SYNCHRONIZE
      ICON:  http://patatapack.oier.ovh/patata-icon.png
      JVM_OPTS: -Dminecraft.api.env=custom -Dminecraft.api.auth.host=https://auth.oier.ovh -Dminecraft.api.account.host=https://auth.oier.ovh/user -Dminecraft.api.session.host=https://auth.oier.ovh/api/yggdrasil -Dminecraft.api.services.host=https://auth.oier.ovh/api/yggdrasil

    networks:
      - patatanet
    volumes:
      - ../patata-data:/data
      #- ./simple-discord-bot.toml:/data/config/simple-discord-bot.toml
  monitor:
    image: itzg/mc-monitor
    command: export-for-prometheus
    environment:
      EXPORT_SERVERS: mc
      DEBUG: "true"
    depends_on:
      - mc
    networks:
      - patatanet
  cadvisor:
    image: gcr.io/cadvisor/cadvisor:v0.47.1
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
    networks:
      - patatanet
  prometheus:
    image: prom/prometheus
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - prometheus-tsdb:/prometheus
    depends_on:
      - monitor
      - minecraft-exporter
      - mc-export
    networks:
      - patatanet
  grafana:
    image: grafana/grafana-oss:${GRAFANA_VERSION:-8.3.3}
    ports:
      - "3000:3000"
    volumes:
      - grafana-lib:/var/lib/grafana
      - ./grafana/provisioning:/etc/grafana/provisioning
      - ./dashboards:/etc/grafana/dashboards
    depends_on:
      - prometheus
    networks:
      - patatanet
  minecraft-exporter:
    build:
      context: ./minecraft-exporter
    environment:
      RCON_HOST: mc
      RCON_PORT: 25575
      RCON_PASSWORD: "${RCON_PASSWORD}"
      FORGE_SERVER: True
    volumes:
      - ../patata-data/world:/world:ro
    depends_on:
      - mc
    networks:
      - patatanet
  mc-export:
    image: ghcr.io/dirien/minecraft-exporter:latest
    environment:
      FORGE_SERVER: True
      MC_WORLD: /world
      MC_RCON_ADDRESS: "mc:25575"
      MC_NAME_SOURCE: offline
      MC_RCON_PASSWORD: "${RCON_PASSWORD}"

    volumes:
      - ../patata-data/world:/world:ro
    depends_on:
      - mc
    networks:
      - patatanet
volumes:
  patata-data: {}
  world: {}
  prometheus-tsdb: {}
  grafana-lib: {}
networks:
  patatanet:
    driver: bridge
