* Add observability * Update * Update * Fix indent * Fix again * Fix againt * fix * Add external address * Fix links * Fixes * Fix * Add IPFS --------- Co-authored-by: folex <0xdxdy@gmail.com>
4.2 KiB
Run rust-peer with docker-compose
This guide explains how to use docker-compose to start a local network of three rust-peer nodes.
Introduction
The rust-peer 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 rust-peer network, you can test your applications in a controlled environment without relying on external networks.
Prerequisites
Before you can run the rust-peer 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 rust-peer network
-
git clone
this repository locally and runcd deploy/docker-compose
. -
Pull the latest container images by running the following command:
docker-compose pull
-
Start the rust-peer network by running the following command:
docker-compose up -d
This will start three rust-peer nodes, each listening on a different port.
Accessing local rust-peer network
To interact with the rust-peer network, you can use the fluence-cli tool.
-
Run
fluence init
and choseminimal
project template. -
Change
hosts
key influence.yaml
to:hosts: defaultWorker: peerIds: - 12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
-
Change
relays
key influence.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
-
Run
fluence run -f 'helloWorld("Fluence")' fluence run -f 'getInfo()'
Using local rust-peer network in your project
You must make changes to fluence.yaml
to use a local rust-peer network:
- changing
hosts
key influence.yaml
to:hosts: defaultWorker: peerIds: - 12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
- changing
relays
key influence.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:
- rust-peer stats - overview of rust-peer network
- Service metrics - detailed stats on deployed services
You can find Grafana at http://localhost:3000. To access rust-peer logs use
Explore
tab and chose Loki
datasource.