forked from cerc-io/stack-orchestrator
Rename app -> stack_orchestrator (#625)
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
# Graph Node
|
||||
|
||||
## Setup
|
||||
|
||||
Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack graph-node setup-repositories --pull
|
||||
```
|
||||
|
||||
Checkout to a non-default branch in the cloned repos if required:
|
||||
|
||||
```bash
|
||||
# Default repo base dir
|
||||
cd ~/cerc
|
||||
|
||||
# Example
|
||||
cd graph-node
|
||||
git checkout <your-branch> && git pull
|
||||
|
||||
# Remove the corresponding docker image if it already exists
|
||||
docker image rm cerc/graph-node:local
|
||||
# Remove any dangling images
|
||||
docker image prune
|
||||
```
|
||||
|
||||
Build the container images:
|
||||
|
||||
```bash
|
||||
laconic-so --stack graph-node build-containers
|
||||
```
|
||||
|
||||
## Create a deployment
|
||||
|
||||
Initialize deployment and create "spec" file:
|
||||
|
||||
```bash
|
||||
laconic-so --stack graph-node deploy init --output graph-node-spec.yml
|
||||
```
|
||||
|
||||
We need to assign fixed ports: `8000` for subgraph GQL endpoint, `8020` for subgraph deployment and `5001` for IPFS. The values can be
|
||||
customized by editing the "spec" file generated by `laconic-so deploy init`.
|
||||
```
|
||||
$ cat graph-node-spec.yml
|
||||
stack: graph-node
|
||||
ports:
|
||||
graph-node:
|
||||
- '8000:8000'
|
||||
- '8001'
|
||||
- '8020:8020'
|
||||
- '8030'
|
||||
ipfs:
|
||||
- '8080'
|
||||
- '4001'
|
||||
- '5001:5001'
|
||||
...
|
||||
```
|
||||
|
||||
Create deployment:
|
||||
|
||||
```bash
|
||||
laconic-so deploy create --spec-file graph-node-spec.yml --deployment-dir graph-node-deployment
|
||||
```
|
||||
|
||||
## Start the stack
|
||||
|
||||
Create an env file with the following values to be set before starting the stack:
|
||||
|
||||
```bash
|
||||
# Set ETH RPC endpoint the graph node will use
|
||||
|
||||
# Host and port of the ETH RPC endpoint to check before starting graph-node
|
||||
export ETH_RPC_HOST=
|
||||
export ETH_RPC_PORT=
|
||||
|
||||
# The etherum network(s) graph-node will connect to
|
||||
# Set this to a space-separated list of the networks where each entry has the form NAME:URL
|
||||
export ETH_NETWORKS=
|
||||
```
|
||||
|
||||
Example env file:
|
||||
|
||||
```bash
|
||||
export ETH_RPC_HOST=filecoin.chainup.net
|
||||
export ETH_RPC_PORT=443
|
||||
|
||||
export ETH_NETWORKS=filecoin:https://filecoin.chainup.net/rpc/v1
|
||||
```
|
||||
|
||||
Set the environment variables:
|
||||
|
||||
```bash
|
||||
source <PATH_TO_ENV_FILE>
|
||||
```
|
||||
|
||||
Deploy the stack:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir graph-node-deployment start
|
||||
|
||||
# Note: Remove any existing volumes in the cluster for a fresh start
|
||||
```
|
||||
|
||||
After all services have started, follow `graph-node` logs:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir graph-node-deployment logs -f graph-node
|
||||
```
|
||||
|
||||
Subgraphs can now be deployed to the graph-node.
|
||||
Follow [Deploy the Subgraph](https://github.com/graphprotocol/graph-node/blob/v0.32.0/docs/getting-started.md#24-deploy-the-subgraph) section in graph-node docs for an existing subgraph.
|
||||
|
||||
## Set environment variables
|
||||
|
||||
* The graph-node environment variable `ETHEREUM_REORG_THRESHOLD` can be set in the deployment compose file
|
||||
```bash
|
||||
$ cat graph-node-deployment/compose/docker-compose-graph-node.yml
|
||||
services:
|
||||
graph-node:
|
||||
image: cerc/graph-node:local
|
||||
...
|
||||
environment:
|
||||
...
|
||||
GRAPH_LOG: debug
|
||||
ETHEREUM_REORG_THRESHOLD: 3
|
||||
```
|
||||
Change `ETHEREUM_REORG_THRESHOLD` to desired value
|
||||
|
||||
* To restart graph-node with updated values
|
||||
* Stop the stack first
|
||||
```bash
|
||||
laconic-so deployment --dir graph-node-deployment stop
|
||||
```
|
||||
* Start the stack again
|
||||
```
|
||||
laconic-so deployment --dir graph-node-deployment start
|
||||
```
|
||||
* To check if environment variable has been updated in graph-node container
|
||||
```bash
|
||||
$ laconic-so deployment --dir graph-node-deployment exec graph-node bash
|
||||
root@dc4d3abe1615:/# echo $ETHEREUM_REORG_THRESHOLD
|
||||
16
|
||||
```
|
||||
|
||||
## Clean up
|
||||
|
||||
Stop all the services running in background run:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir graph-node-deployment stop
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir graph-node-deployment stop --delete-volumes
|
||||
```
|
||||
@@ -0,0 +1,68 @@
|
||||
# Deploying Subgraph
|
||||
|
||||
## Setup
|
||||
|
||||
We will use the [ethereum-gravatar](https://github.com/graphprotocol/graph-tooling/tree/%40graphprotocol/graph-cli%400.58.0/examples/ethereum-gravatar) example subgraph from `graphprotocol/graph-tooling` repo
|
||||
|
||||
- Clone the repo
|
||||
```bash
|
||||
git clone git@github.com:graphprotocol/graph-tooling.git
|
||||
|
||||
cd graph-tooling
|
||||
```
|
||||
|
||||
- Install dependencies
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
- Change directory to example-subgraph
|
||||
```bash
|
||||
cd examples/ethereum-gravatar
|
||||
```
|
||||
|
||||
## Deploy
|
||||
|
||||
The following steps should be similar for every subgraph
|
||||
|
||||
- Change the network and address in `subgraph.yaml`
|
||||
```yaml
|
||||
...
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: Gravity
|
||||
network: <NETWORK_NAME>
|
||||
source:
|
||||
address: '<CONTRACT_ADDRESS>'
|
||||
abi: Gravity
|
||||
startBlock: <START_BLOCK>
|
||||
...
|
||||
```
|
||||
- `CONTRACT_ADDRESS` is the address of the deployed contract on the desired network
|
||||
- `START_BLOCK` is the block number after which we want to process events
|
||||
- `NETWORK_NAME` is the name of the network specified when deploying graph-node
|
||||
- When deploying graph-node `ETH_NETWORKS` env is set to a space-separated list of the networks where each entry has the form `NAME:URL`
|
||||
- The `NAME` can be used in subgraph to specify which network to use
|
||||
- More details can be seen in [Start the stack](./README.md#start-the-stack) section
|
||||
|
||||
- Build the subgraph
|
||||
```bash
|
||||
pnpm codegen
|
||||
pnpm build
|
||||
```
|
||||
|
||||
- Create and deploy the subgraph
|
||||
```bash
|
||||
pnpm graph create example --node <GRAPH_NODE_DEPLOY_ENDPOINT>
|
||||
|
||||
pnpm graph deploy example --ipfs <GRAPH_NODE_IPFS_ENDPOINT> --node <GRAPH_NODE_DEPLOY_ENDPOINT>
|
||||
```
|
||||
- `GRAPH_NODE_DEPLOY_ENDPOINT` and `GRAPH_NODE_IPFS_ENDPOINT` will be available after graph-node has been deployed
|
||||
- More details can be seen in [Create a deployment](./README.md#create-a-deployment) section
|
||||
|
||||
- The subgraph GQL endpoint will be seen after deploy command runs successfully
|
||||
|
||||
- To remove the subgraph
|
||||
```bash
|
||||
pnpm graph remove --node <GRAPH_NODE_DEPLOY_ENDPOINT> example
|
||||
```
|
||||
@@ -0,0 +1,9 @@
|
||||
version: "1.0"
|
||||
name: graph-node
|
||||
description: "Stack for running graph-node"
|
||||
repos:
|
||||
- github.com/graphprotocol/graph-node
|
||||
containers:
|
||||
- cerc/graph-node
|
||||
pods:
|
||||
- graph-node
|
||||
Reference in New Issue
Block a user