version: "3.9"

services:
  net1:
    image: 192.168.1.220:5000/metanet:v0.0.1
    container_name: net1
    entrypoint: /root/MetaNet --single-node --enable-prom --log-level debug --p2p-priv-key /root/default-priv-key --grpc-host 0.0.0.0 --grpc-port 38010 --p2p-host-ip 172.99.1.1
    ports:
      - "38010:38010"
    volumes:
      - ./data/net1:/root/data
    deploy:
      restart_policy:
        condition: on-failure
        delay: 15s
        max_attempts: 100
        window: 120s
    networks:
      meta:
        ipv4_address: 172.99.1.1

  net2:
    image: 192.168.1.220:5000/metanet:v0.0.1
    container_name: net2
    entrypoint: /root/MetaNet --single-node --enable-prom --log-level debug --peer /ip4/172.99.1.1/tcp/30333/p2p/16Uiu2HAm3pzLayNahJtkYHaxWFMibZ7RuyG8BRsdj1YQRvwWYKM5 --grpc-host 0.0.0.0 --grpc-port 38010 --p2p-host-ip 172.99.1.2
    ports:
      - "38011:38010"
    volumes:
      - ./data/net2:/root/data
    deploy:
      restart_policy:
        condition: on-failure
        delay: 15s
        max_attempts: 100
        window: 120s
    depends_on:
      - net1
    networks:
      meta:
        ipv4_address: 172.99.1.2

  nebula1:
    image: 192.168.1.220:5000/nebula:v0.0.1
    container_name: nebula1
    depends_on:
      - net1
      - net2
      - sentry
    deploy:
      restart_policy:
        condition: on-failure
        delay: 15s
        max_attempts: 100
        window: 120s
    volumes:
      - ./nebula/config.toml:/root/config.toml
      - ./nebula/genesis.json:/root/genesis.json
      - ./data/nebula:/root/data
    networks:
      - meta

  nebula2:
    image: 192.168.1.220:5000/nebula:v0.0.1  
    container_name: nebula2
    depends_on:
      - net1
      - net2
      - sentry
    deploy:
      restart_policy:
        condition: on-failure
        delay: 15s
        max_attempts: 100
        window: 120s
    volumes:
      - ./nebula/config.toml:/root/config.toml
      - ./nebula/genesis.json:/root/genesis.json
      - ./data/nebula2:/root/data
    networks:
      - meta

  cryptor1:
    image: 192.168.1.220:5000/cryptor:v0.0.1 
    container_name: cryptor1
    deploy:
      restart_policy:
        condition: on-failure
        delay: 15s
        max_attempts: 100
        window: 120s
    volumes:
      - ./cryptor/config.toml:/root/config.toml
    networks:
      - meta

  cryptor2:
    image: 192.168.1.220:5000/cryptor:v0.0.1 
    container_name: cryptor2
    deploy:
      restart_policy:
        condition: on-failure
        delay: 15s
        max_attempts: 100
        window: 120s
    volumes:
      - ./cryptor/config.toml:/root/config.toml
    networks:
      - meta

  sentry:
    image: 192.168.1.220:5000/sentry:v0.0.1 
    container_name: sentry
    deploy:
      restart_policy:
        condition: on-failure
        delay: 15s
        max_attempts: 100
        window: 120s
    volumes:
      - ./sentry/app.json:/root/app.json
    networks:
      - meta

  ring1:
    image: 192.168.1.220:5000/ring:v0.0.1
    container_name: ring1
    entrypoint: sh -c 'echo "ring" && sleep 10 && ringd start  --ethconfig.httphost  0.0.0.0 --mempool.sentryurl  sentry:38003   --mempool.nebulaurl nebula1:38004  --mempool.p2purl  net:38010  --mempool.cryptourl  cryptor1:38001  --mempool.checkerurl txchecker:38002   --mempool.writeunreadytxs=false   --mempool.writerepeatedmsg=false     --mempool.batchconfirminittimeout=60   --mempool.batchconfirmtimeouti=1.5 --mempool.batchrepeatedqueuesize=0 >> /data/log' #>> /data/log
    volumes:
      - ./data/metaring1:/data
    depends_on:
      - cryptor1
      - net1
      - net2
      - sentry
    deploy:
      resources:
        limits:
          cpus: "36.00"
          memory: 50G
        reservations:
          cpus: "30.00"
          memory: 50G
      restart_policy:
        condition: on-failure
        delay: 15s
        max_attempts: 100
        window: 120s
    ports:
      - 8545:8545
      - 5001:5001
      - 38020:38020
      - 6060:6060
    networks:
      - meta

  ring2:
    image: 192.168.1.220:5000/ring:v0.0.1
    container_name: ring2
    entrypoint: sh -c 'echo "ring" && sleep 1 && ringd start  --ethconfig.httphost  0.0.0.0 --mempool.sentryurl  sentry:38003   --mempool.nebulaurl nebula2:38004  --mempool.p2purl  net2:38010  --mempool.cryptourl  cryptor2:38001  --mempool.checkerurl txchecker:38002   --mempool.writeunreadytxs=false   --mempool.writerepeatedmsg=false     --mempool.batchconfirminittimeout=60   --mempool.batchconfirmtimeouti=1.5 --mempool.batchrepeatedqueuesize=0 >> /data/log' #>> /data/log
    volumes:
      - ./data/metaring2:/data
    depends_on:
      - cryptor2
      - net1
      - net2
      - sentry
    deploy:
      resources:
        limits:
          cpus: "36.00"
          memory: 50G
        reservations:
          cpus: "30.00"
          memory: 50G
      restart_policy:
        condition: on-failure
        delay: 15s
        max_attempts: 100
        window: 120s
    ports:
      - 8546:8545
      - 5002:5001
      - 38021:38020
      - 6061:6060
    networks:
      - meta

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
      - "9090:9090"
    command:
      - --config.file=/etc/prometheus/prometheus.yml
    volumes:
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
    depends_on:
      - cadvisor
    networks:
      - meta

  cadvisor:
    #image: gcr.io/cadvisor/cadvisor:latest
    image: google/cadvisor:latest
    container_name: cadvisor
    ports:
      - "8080:8080"
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
    depends_on:
      - ring1
      - ring2
      - net1
      - net2
      - sentry
      - nebula1
      - nebula2
    networks:
      - meta

networks:
  meta:
    driver: bridge
    ipam:
      config:
        - subnet: 172.99.0.0/16
