version: "3.4"

services:
  duniter-rpc:
    image: duniter/duniter-v2s:v0.4.0
    restart: unless-stopped
    ports:
      # telemetry
      - 127.0.0.1:9615:9615
      # rpc
      - 127.0.0.1:9933:9933
      # rpc-ws
      - 127.0.0.1:9944:9944
      # p2p
      - 30333:30333
    volumes:
      - ./node.key:/etc/duniter/validator-node.key
      - duniter-rpc-data:/var/lib/duniter/
    environment:
      - DUNITER_CHAIN_NAME=gdev
    command:
      - "--node-key-file=/var/lib/duniter/node.key"
      - "--public-addr"
      # SERVER_DOMAIN should be replaced by a domain name that point on your server
      #
      # The PEER_ID should be replaced by the output of this command:
      # docker run --rm -it --entrypoint -v $PWD/duniter-rpc/:/var/lib/duniter/ duniter duniter/duniter-v2s:v0.4.0 key generate-node-key --file /var/lib/duniter/node.key
      - "/dns/${SERVER_DOMAIN?SERVER_DOMAIN should be set}/tcp/30333/p2p/${PEER_ID?PEER_ID should be set}"
      - "--rpc-cors=all"

  duniter-validator:
    image: duniter/duniter-v2s:v0.4.0
    restart: unless-stopped
    ports:
      # telemetry
      - 127.0.0.1:9616:9615
      # rpc
      - 127.0.0.1:9934:9933
      # rpc-ws
      - 127.0.0.1:9945:9944
      # p2p
      - 30334:30333
    volumes:
      - ./node.key:/etc/duniter/validator-node.key
      - duniter-validator-data:/var/lib/duniter/
    environment:
      - DUNITER_CHAIN_NAME=gdev
    command:
      - "--node-key-file=/var/lib/duniter/node.key"
      - "--public-addr"
      - "--pruning=14400"
      # SERVER_DOMAIN should be replaced by a domain name that point on your server
      #
      # The VALIDATOR_PEER_ID should be replaced by the output of this command:
      # docker run --rm -it --entrypoint -v $PWD/duniter-rpc/:/var/lib/duniter/ duniter duniter/duniter-v2s:v0.4.0 key generate-node-key --file /var/lib/duniter/node.key
      - "/dns/${SERVER_DOMAIN?SERVER_DOMAIN should be set}/tcp/30333/p2p/${VALIDATOR_PEER_ID?VALIDATOR_PEER_ID should be set}"
      - "--rpc-cors=all"
      - "--rpc-methods=Unsafe"
      - "--validator"
