dev instructions tweaks (#27)

* dev instructions tweaks

* tweak deployment instruction

* fix typo
This commit is contained in:
Matthias Kretschmann 2021-02-10 13:03:47 +01:00 committed by GitHub
parent 8bce5f3df2
commit 3510edf98f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,18 +11,17 @@
- [🧶 Example Queries](#-example-queries) - [🧶 Example Queries](#-example-queries)
- [🦑 Development](#-development) - [🦑 Development](#-development)
- [✨ Code Style](#-code-style) - [✨ Code Style](#-code-style)
- [⬆️ Releases](#-releases) - [🛳 Releases](#-releases)
- [🛳 Production](#-production)
- [⬆️ Deployment](#-deployment) - [⬆️ Deployment](#-deployment)
- [🏛 License](#-license) - [🏛 License](#-license)
## 🏄 Get Started ## 🏄 Get Started
This subgraph is deployed for all networks the Ocean Protocol contracts are deployed to: This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/` namespace for all networks the Ocean Protocol contracts are deployed to:
- [subgraph.mainnet.oceanprotocol.com](https://subgraph.mainnet.oceanprotocol.com) - [subgraph.mainnet.oceanprotocol.com](https://subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
- [subgraph.ropsten.oceanprotocol.com](https://subgraph.ropsten.oceanprotocol.com) - [subgraph.ropsten.oceanprotocol.com](https://subgraph.ropsten.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
- [subgraph.rinkeby.oceanprotocol.com](https://subgraph.ropsten.oceanprotocol.com) - [subgraph.rinkeby.oceanprotocol.com](https://subgraph.rinkeby.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
## 🧶 Example Queries ## 🧶 Example Queries
@ -75,27 +74,33 @@ This subgraph is deployed for all networks the Ocean Protocol contracts are depl
## 🦑 Development ## 🦑 Development
Prepare the docker setup: First, clone the repo and install dependencies:
```bash
git clone https://github.com/oceanprotocol/ocean-subgraph/
cd ocean-subgraph
npm i
```
Developing and testing any change requires them to be deployed against a locally running graph-node and some other components running in Docker. Make sure you have Docker and Docker Compose installed on your machine, then prepare the Docker setup:
```bash ```bash
cd docker cd docker
./setup.sh ./setup.sh
``` ```
Edit docker-compose and add your infura key & network
Start : Then add your Infura key as environment variable with a `.env` file, and start everything up with Docker Compose:
```bash
docker-compose up
```
To use with ifura key create a .env file (look at .env.example)
```bash ```bash
# create .env and modify
cp .env.example .env
docker-compose --env-file .env up docker-compose --env-file .env up
``` ```
Switch to a new terminal: The default network for development is set to Rinkeby. If you want to switch to another network you have to modify the `docker/docker-compose.yml` file within `environment.ethereum`.
To deploy the ocean-subgraph to graph-node, see the `Deployment` section below. You now have a local graph-node running and can start deploying your changes to it. To do so, follow the [Deployment instructions](#-deployment).
You can make changes to the event handlers and/or features and re-deploy, again see the `Deployment` section below.
## ✨ Code Style ## ✨ Code Style
@ -109,7 +114,7 @@ npm run lint
npm run format npm run format
``` ```
## ⬆️ Releases ## 🛳 Releases
Releases are managed semi-automatically. They are always manually triggered from a developer's Releases are managed semi-automatically. They are always manually triggered from a developer's
machine with release scripts. From a clean `main` branch you can run the release task bumping machine with release scripts. From a clean `main` branch you can run the release task bumping
@ -130,35 +135,42 @@ The task does the following:
For the GitHub releases steps a GitHub personal access token, exported as `GITHUB_TOKEN` is required. [Setup](https://github.com/release-it/release-it#github-releases) For the GitHub releases steps a GitHub personal access token, exported as `GITHUB_TOKEN` is required. [Setup](https://github.com/release-it/release-it#github-releases)
## 🛳 Production
## ⬆️ Deployment ## ⬆️ Deployment
- Do the following to deploy the ocean-subgraph to a graph-node running locally:
Do the following to deploy the ocean-subgraph to a graph-node running locally, pointed against `mainnet`:
```bash ```bash
git clone https://github.com/oceanprotocol/ocean-subgraph/
cd ocean-subgraph
npm i
npm run codegen npm run codegen
# deploy
npm run create:local npm run create:local
npm run deploy:local npm run deploy:local
``` ```
The above will deploy ocean-subgraph connecting to mainnet. To create/deploy subgraph connecting to Rinkeby or Ropsten test net, To deploy a subgraph connected to Rinkeby or Ropsten test networks, use instead:
use :local-rinkeby or :local-ropsten with either create or deploy command.
- You can edit the event handler code and then run `npm run deploy:local` ```bash
- Running deploy will fail if the code has no changes # Rinkeby
- Sometimes deploy will fail no matter what, in this case: npm run create:local-rinkeby
- Stop the docker-compose run (`docker-compose down` or Ctrl+C) npm run deploy:local-rinkeby
# Ropsten
npm run create:local-ropsten
npm run deploy:local-ropsten
```
You can edit the event handler code and then run `npm run deploy:local`, with some caveats:
- Running deploy will fail if the code has no changes
- Sometimes deploy will fail no matter what, in this case:
- Stop the docker-compose run (`docker-compose down` or Ctrl+C)
This should stop the graph-node, ipfs and postgres containers This should stop the graph-node, ipfs and postgres containers
- Delete the `ipfs` and `postgres` folders in `/docker/data` (`rm -rf ./docker/data/*`) - Delete the `ipfs` and `postgres` folders in `/docker/data` (`rm -rf ./docker/data/*`)
- Run `docker-compose up` to restart graph-node, ipfs and postgres - Run `docker-compose up` to restart graph-node, ipfs and postgres
- Run `npm run create:local` to create the ocean-subgraph - Run `npm run create:local` to create the ocean-subgraph
- Run `npm run deploy:local` to deploy the ocean-subgraph - Run `npm run deploy:local` to deploy the ocean-subgraph
Note: to deploy to one of the remote nodes run by Ocean, you can do port-forwarding then using the > To deploy to one of the remote nodes run by Ocean, you can do port-forwarding and the above `:local` commands will work as is.
above `local` create/deploy commands will work as is.
## 🏛 License ## 🏛 License