Setup env config and update script for running a node
This commit is contained in:
parent
7adddacc72
commit
a37e5ab1f2
@ -3,6 +3,12 @@ services:
|
||||
restart: no
|
||||
image: cerc/laconic2d:local
|
||||
command: ["/bin/sh", "-c", "/opt/run-laconicd.sh"]
|
||||
environment:
|
||||
CERC_MONIKER: ${CERC_MONIKER:-TestnetNode}
|
||||
CERC_CHAIN_ID: ${CERC_CHAIN_ID:-laconic_9000-1}
|
||||
CERC_GENESIS_FILE_URL: ${CERC_GENESIS_FILE_URL:-"file:///root/.laconicd/config/genesis.json"}
|
||||
CERC_PEERS: ${CERC_PEERS}
|
||||
CERC_LOGLEVEL: ${CERC_LOGLEVEL:-info}
|
||||
volumes:
|
||||
- laconicd-data:/root/.laconicd/data
|
||||
- laconicd-config:/root/.laconicd/config
|
||||
@ -17,8 +23,16 @@ services:
|
||||
- "26656"
|
||||
- "9473"
|
||||
- "9090"
|
||||
- "9091"
|
||||
- "1317"
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "127.0.0.1:26657"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
cli:
|
||||
image: cerc/laconic-registry-cli:local
|
||||
volumes:
|
||||
|
@ -1,47 +1,44 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
set -x
|
||||
fi
|
||||
|
||||
# TODO: Read from env
|
||||
MONIKER=MyNode
|
||||
CHAIN_ID=laconic_9000-1
|
||||
GENESIS_FILE_URL="/root/.laconicd/config/genesis.json"
|
||||
PEERS=""
|
||||
LOGLEVEL="info"
|
||||
set -e
|
||||
|
||||
if [ -z "$PEERS" ]; then
|
||||
if [ -z "$CERC_PEERS" ]; then
|
||||
echo "Persistent peers not provided, exiting..."
|
||||
exit 1
|
||||
else
|
||||
echo "Using persistent peers $PEERS"
|
||||
echo "Using persistent peers $CERC_PEERS"
|
||||
fi
|
||||
|
||||
echo "Env:"
|
||||
echo "Moniker: $MONIKER"
|
||||
echo "Chain Id: $CHAIN_ID"
|
||||
echo "Genesis file: $GENESIS_FILE_URL"
|
||||
echo "Persistent peers: $PEERS"
|
||||
echo "Moniker: $CERC_MONIKER"
|
||||
echo "Chain Id: $CERC_CHAIN_ID"
|
||||
echo "Genesis file: $CERC_GENESIS_FILE_URL"
|
||||
echo "Persistent peers: $CERC_PEERS"
|
||||
echo "Log level: $CERC_LOGLEVEL"
|
||||
|
||||
NODE_HOME=/root/.laconicd
|
||||
|
||||
# Set chain id in config
|
||||
laconicd config set client chain-id $CHAIN_ID --home $NODE_HOME
|
||||
laconicd config set client chain-id $CERC_CHAIN_ID --home $NODE_HOME
|
||||
|
||||
# Check if node data dir already exists
|
||||
if [ -z "$(ls -A "$NODE_HOME/data")" ]; then
|
||||
# Init node
|
||||
echo "Initializing a new laconicd node with moniker $MONIKER and chain id $CHAIN_ID"
|
||||
laconicd init $MONIKER --chain-id=$CHAIN_ID --home $NODE_HOME
|
||||
echo "Initializing a new laconicd node with moniker $CERC_MONIKER and chain id $CERC_CHAIN_ID"
|
||||
laconicd init $CERC_MONIKER --chain-id=$CERC_CHAIN_ID --home $NODE_HOME
|
||||
|
||||
# Fetch genesis config
|
||||
echo "Fetching genesis file from $GENESIS_FILE_URL"
|
||||
curl -o $NODE_HOME/config/genesis.json $GENESIS_FILE_URL
|
||||
echo "Fetching genesis file from $CERC_GENESIS_FILE_URL"
|
||||
curl -o $NODE_HOME/config/genesis.json $CERC_GENESIS_FILE_URL
|
||||
else
|
||||
echo "Node data dir $NODE_HOME/data already exists, skipping initialization..."
|
||||
fi
|
||||
|
||||
# Update config with persistent peers
|
||||
sed -i "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/g" $NODE_HOME/config/config.toml
|
||||
sed -i "s/^persistent_peers *=.*/persistent_peers = \"$CERC_PEERS\"/g" $NODE_HOME/config/config.toml
|
||||
|
||||
laconicd start --gql-playground --gql-server --log_level $LOGLEVEL --home $NODE_HOME
|
||||
laconicd start --gql-playground --gql-server --log_level $CERC_LOGLEVEL --home $NODE_HOME
|
||||
|
@ -33,10 +33,57 @@ This should create several container images in the local image registry:
|
||||
* cerc/webapp-base
|
||||
* cerc/laconic-console-host
|
||||
|
||||
## Deploy the stack
|
||||
## Create a spec file for the deployment
|
||||
|
||||
```bash
|
||||
laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconicd-full-node deploy up
|
||||
laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconicd-full-node deploy init --output laconic-full-node-spec.yml
|
||||
```
|
||||
|
||||
## Ports
|
||||
|
||||
Edit `network` in the spec file to map container ports to host ports as required:
|
||||
|
||||
```bash
|
||||
...
|
||||
network:
|
||||
# TODO: UPDATE
|
||||
ports:
|
||||
laconicd:
|
||||
- '6060:6060'
|
||||
- '26657:26657'
|
||||
- '26656:26656'
|
||||
- '9473:9473'
|
||||
- '9090:9090'
|
||||
- '1317:1317'
|
||||
```
|
||||
|
||||
## Create a deployment from the spec file
|
||||
|
||||
```bash
|
||||
laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconicd-full-node deploy create --spec-file laconic-full-node-spec.yml --deployment-dir laconic-full-node-deployment
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
Copy genesis file to the deployment data directory:
|
||||
|
||||
```bash
|
||||
# Example
|
||||
cp genesis.json laconic-full-node-deployment/data/laconicd-config/
|
||||
```
|
||||
|
||||
Inside deployment directory, open the `config.env` file and set following env variables:
|
||||
|
||||
```bash
|
||||
# TODO: UPDATE
|
||||
# External Filecoin (ETH RPC) endpoint to point the watcher to
|
||||
CERC_PEERS=""
|
||||
```
|
||||
|
||||
## Start the deployment
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir laconic-full-node-deployment start
|
||||
```
|
||||
|
||||
## Check status
|
||||
@ -54,7 +101,7 @@ laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/lacon
|
||||
Stop all services running in the background:
|
||||
|
||||
```bash
|
||||
laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconicd-full-node deploy down
|
||||
laconic-so deployment --dir laconic-full-node-deployment stop
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
|
Loading…
Reference in New Issue
Block a user