diff --git a/GraphNodeDockerfile b/GraphNodeDockerfile new file mode 100644 index 0000000..4b103a1 --- /dev/null +++ b/GraphNodeDockerfile @@ -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} + diff --git a/README.md b/README.md index 34fb0a0..deaaa69 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0c4024a --- /dev/null +++ b/docker-compose.yml @@ -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 \ No newline at end of file diff --git a/package.json b/package.json index fda9377..11077d7 100644 --- a/package.json +++ b/package.json @@ -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",