node-distro/deploy/docker-compose
Anatolios Laskaris 52e8475ec6
chore: Enable builtin services explicitly (#183)
Enable builtin services explicitly
2023-10-16 13:45:58 +03:00
..
configs chore(naming): Rename rust-peer to nox (#152) 2023-06-06 14:52:27 -06:00
grafana chore(naming): Rename rust-peer to nox (#152) 2023-06-06 14:52:27 -06:00
docker-compose.observability.yml chore: Add observability to docker-compose (#113) 2023-03-22 17:59:01 +02:00
docker-compose.yml chore: Enable builtin services explicitly (#183) 2023-10-16 13:45:58 +03:00
ipfs.sh chore: Add observability to docker-compose (#113) 2023-03-22 17:59:01 +02:00
README.md chore(naming): Rename rust-peer to nox (#152) 2023-06-06 14:52:27 -06:00

Run nox with docker-compose

This guide explains how to use docker-compose to start a local network of three nox nodes.

Introduction

The nox network is a set of peer nodes that can communicate with each other to share data and execute code plus local IPFS node used by aqua-ipfs builtin. By running a local nox network, you can test your applications in a controlled environment without relying on external networks.

Prerequisites

Before you can run the nox network, you need to have Docker and docker-compose installed on your system. You can follow the official instructions for installing Docker and installing docker-compose on your operating system:

Starting local nox network

  1. git clone this repository locally and run cd deploy/docker-compose.

  2. Pull the latest container images by running the following command:

    docker-compose pull
    
  3. Start the nox network by running the following command:

    docker-compose up -d
    

This will start three nox nodes, each listening on a different port.

Accessing local nox network

To interact with the nox network, you can use the fluence-cli tool.

  1. Run fluence init and chose minimal project template.

  2. Change hosts key in fluence.yaml to:

    hosts:
      defaultWorker:
        peerIds:
          - 12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
    
  3. Change relays key in fluence.yaml to:

    relays:
      - /ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
      - /ip4/127.0.0.1/tcp/9992/ws/p2p/12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK
      - /ip4/127.0.0.1/tcp/9993/ws/p2p/12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ
    
  4. Run

    fluence run -f 'helloWorld("Fluence")'
    fluence run -f 'getInfo()'
    

Using local nox network in your project

You must make changes to fluence.yaml to use a local nox network:

  • changing hosts key in fluence.yaml to:
    hosts:
      defaultWorker:
        peerIds:
          - 12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
    
  • changing relays key in fluence.yaml to:
    relays:
      - /ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
      - /ip4/127.0.0.1/tcp/9992/ws/p2p/12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK
      - /ip4/127.0.0.1/tcp/9993/ws/p2p/12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ
    

You can try following the example workflow provided by Fluence Labs making these changes.

Here is a table with multiaddress for each node:

container multiaddress
peer-1 /ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
peer-2 /ip4/127.0.0.1/tcp/9992/ws/p2p/12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK
peer-3 /ip4/127.0.0.1/tcp/9993/ws/p2p/12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ

Running with observability stack

Stack consists of:

  • Prometheus - TSDB that collects and stores metrics
  • Loki - lightweight centralized logging solution
  • Promtail - log collection agent
  • Grafana - data visualization tool

To set it up run:

docker-compose -f docker-compose.yml -f docker-compose.observability.yml up -d

Grafana will have automatically preprovisioned dashboards:

  • nox stats - overview of nox network
  • Service metrics - detailed stats on deployed services

You can find Grafana at http://localhost:3000. To access nox logs use Explore tab and chose Loki datasource.