Skip to content

Commit

Permalink
chore: create working version of docker graph-node
Browse files Browse the repository at this point in the history
  • Loading branch information
cleivson committed Mar 13, 2023
1 parent 2828bde commit 0f07826
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 3 deletions.
15 changes: 15 additions & 0 deletions GraphNodeDockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM rust:1.67

RUN apt-get update && apt-get install git -y

RUN git clone https://github.com/graphprotocol/graph-node

RUN apt-get install protobuf-compiler clang libpq-dev libssl-dev pkg-config -y

WORKDIR /graph-node

RUN \
cargo build --release

CMD cargo run --release -- --postgres-url postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/graph-node --ethereum-rpc ${NODE_NETWORK}:full:${NODE_RPC_URL} --ipfs ${IPFS_HOST}

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Benqi-subgraph

### Prerequisites:
- Graph-cli: https://github.com/graphprotocol/graph-tooling/tree/main/packages/cli

#### To run a graph-node on your local computer
- Graph-node: https://github.com/graphprotocol/graph-node

#### To run a graph-node on docker
- Docker: https://docs.docker.com/engine/
- Setup on host machine: https://github.com/fmedv/docker-go-ipfs#setup-pre-configuration

Sometimes the graph-node process starts up faster than the ipfs, so it's safer to run 2 separate commands:
`docker-compose up -d graph-db ipfs`
`docker-compose up graph-node`

### Commands:

generate types:
Expand Down
48 changes: 48 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: "3.7"
services:
graph-db:
image: postgres:15
restart: always
volumes:
- ../db_data:/var/lib/postgresql/data
ports:
- "5432:5432" #console
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgrespassword
POSTGRES_DB: graph-node
POSTGRES_INITDB_ARGS: "--locale-provider=icu --icu-locale=C"
LC_ALL: "C"
LC_CTYPE: "C"
command: ["postgres", "-c", "log_statement=all"]
ipfs:
image: ipfs/kubo:master-2023-02-02-14649aa
restart: always
volumes:
- ../ipfs/staging:/export
- ../ipfs/data:/data/ipfs
ports:
- "4001:4001"
- "4001:4001/udp"
- "127.0.0.1:8080:8080"
- "127.0.0.1:5001:5001"
graph-node:
build:
context: .
dockerfile: GraphNodeDockerfile
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgrespassword
POSTGRES_HOST: graph-db:5432
IPFS_HOST: ipfs:5001
NODE_NETWORK: avalanche
NODE_RPC_URL: http://avalanche05.ct.romenet.io:9650/ext/bc/C/rpc
ports:
- "8000:8000"
- "8001:8001"
- "8020:8020"
- "8030:8030"
- "8040:8040"
depends_on:
- graph-db
- ipfs
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "benqi-v1-avalanche",
"license": "MIT",
"scripts": {
"codegen": "npx graph codegen --output-dir src/types/",
"build": "npx graph build",
"codegen": "graph codegen --output-dir src/types/",
"build": "graph build",
"deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ token-terminal/benqi-v1-avalanche",
"create-local": "graph create --node http://localhost:8020/ token-terminal/benqi-v1-avalanche",
"remove-local": "graph remove --node http://localhost:8020/ token-terminal/benqi-v1-avalanche",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 token-terminal/benqi-v1-avalanche"
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 token-terminal/benqi-v1-avalanche",
"test": "graph test"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.20.1",
Expand Down

0 comments on commit 0f07826

Please sign in to comment.