# Docker compose file to start a multi node local test network.
#
# # Nodes
#
# - Validator node A
# - Validator node B
# - Light client C
#
# # Auxiliary nodes
#
# - Prometheus monitoring each node.
# - Grafana pointed at the Prometheus node, configured with all dashboards.
#
# # Usage
#
# 1. Build `target/release/substrate` binary: `cargo build --release`
# 2. Start networks and containers:
#    `sudo docker-compose -f .maintain/sentry-node/docker-compose.yml up`
# 3. Connect to nodes:
#   - validator-a: localhost:9944
#   - validator-b: localhost:9945
#   - light-c: localhost:9946
#   - via polkadot.js/apps: https://polkadot.js.org/apps/?rpc=ws%3A%2F%2Flocalhost%3A<NODE_PORT>#/explorer
#   - grafana: localhost:3001
#   - prometheus: localhost:9090


version: "3.7"
services:

  validator-a:
    ports:
      - "9944:9944"
      - "9615:9615"
    volumes:
      - ../../target/release/substrate:/usr/local/bin/substrate
    image: parity/substrate
    networks:
      - internet
    command:
      - "--node-key"
      - "0000000000000000000000000000000000000000000000000000000000000001"
      - "--base-path"
      - "/tmp/alice"
      - "--chain=local"
      - "--port"
      - "30333"
      - "--validator"
      - "--alice"
      - "--bootnodes"
      - "/dns/validator-b/tcp/30333/p2p/12D3KooWHdiAxVd8uMQR1hGWXccidmfCwLqcMpGwR6QcTP6QRMuD"
      # Not only bind to localhost.
      - "--unsafe-ws-external"
      - "--unsafe-rpc-external"
      - "--log"
      - "sub-libp2p=trace"
      - "--no-telemetry"
      - "--rpc-cors"
      - "all"
      - "--prometheus-external"

  validator-b:
    image: parity/substrate
    ports:
      - "9945:9944"
    volumes:
      - ../../target/release/substrate:/usr/local/bin/substrate
    networks:
      - internet
    command:
      - "--node-key"
      - "0000000000000000000000000000000000000000000000000000000000000002"
      - "--base-path"
      - "/tmp/bob"
      - "--chain=local"
      - "--port"
      - "30333"
      - "--validator"
      - "--bob"
      - "--bootnodes"
      - "/dns/validator-a/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"
      - "--no-telemetry"
      - "--rpc-cors"
      - "all"
      # Not only bind to localhost.
      - "--unsafe-ws-external"
      - "--unsafe-rpc-external"
      - "--log"
      - "sub-libp2p=trace"
      - "--prometheus-external"

  light-c:
    image: parity/substrate
    ports:
      - "9946:9944"
    volumes:
      - ../../target/release/substrate:/usr/local/bin/substrate
    networks:
      - internet
    command:
      - "--node-key"
      - "0000000000000000000000000000000000000000000000000000000000000003"
      - "--base-path"
      - "/tmp/light"
      - "--chain=local"
      - "--port"
      - "30333"
      - "--light"
      - "--bootnodes"
      - "/dns/validator-a/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"
      - "--bootnodes"
      - "/dns/validator-b/tcp/30333/p2p/12D3KooWHdiAxVd8uMQR1hGWXccidmfCwLqcMpGwR6QcTP6QRMuD"
      - "--no-telemetry"
      - "--rpc-cors"
      - "all"
      # Not only bind to localhost.
      - "--unsafe-ws-external"
      - "--unsafe-rpc-external"
      - "--log"
      - "sub-libp2p=trace"
      - "--prometheus-external"

  prometheus:
    image: prom/prometheus
    networks:
      - internet
    ports:
      - "9090:9090"
    links:
      - validator-a:validator-a
      - validator-b:validator-b
      - light-c:light-c
    volumes:
      - ./prometheus/:/etc/prometheus/
    restart: always

  grafana:
    image: grafana/grafana
    user: "104"
    depends_on:
      - prometheus
    networks:
      - internet
    ports:
      - 3001:3000
    volumes:
      - ./grafana/provisioning/:/etc/grafana/provisioning
      - ../monitoring/grafana-dashboards/:/etc/grafana/provisioning/dashboard-definitions
    restart: always

networks:
  network-a:
  internet:
