Add compose file and stack instructions for sushiswap

This commit is contained in:
IshaVenikar 2024-06-14 13:50:24 +05:30
parent beb14ab9c8
commit b17608f6a4
3 changed files with 192 additions and 0 deletions

View File

@ -0,0 +1,80 @@
version: '3.2'
services:
sushiswap-watcher-db:
restart: unless-stopped
image: postgres:14-alpine
environment:
- POSTGRES_USER=vdbm
- POSTGRES_MULTIPLE_DATABASES=sushiswap-watcher,sushiswap-watcher-job-queue
- POSTGRES_EXTENSION=sushiswap-watcher-job-queue:pgcrypto
- POSTGRES_PASSWORD=password
volumes:
- ../config/postgresql/multiple-postgressql-databases.sh:/docker-entrypoint-initdb.d/multiple-postgressql-databases.sh
- sushiswap_watcher_db_data:/var/lib/postgresql/data
ports:
- "5432"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "5432"]
interval: 20s
timeout: 5s
retries: 15
start_period: 10s
sushiswap-watcher-job-runner:
restart: unless-stopped
depends_on:
sushiswap-watcher-db:
condition: service_healthy
image: cerc/watcher-sushiswap:local
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_ETH_RPC_ENDPOINTS: ${CERC_ETH_RPC_ENDPOINTS}
working_dir: /app/packages-watcher
command: ["bash", "./start-job-runner.sh"]
volumes:
- ../config/watcher-sushiswap/watcher-config-template.toml:/app/packages-watcher/environments/watcher-config-template.toml
- ../config/common/start-job-runner.sh:/app/packages-watcher/start-job-runner.sh
ports:
- "9000:9000"
healthcheck:
test: ["CMD", "nc", "-vz", "127.0.0.1", "9000"]
interval: 20s
timeout: 5s
retries: 15
start_period: 5s
extra_hosts:
- "host.docker.internal:host-gateway"
sushiswap-watcher-server:
restart: unless-stopped
depends_on:
sushiswap-watcher-db:
condition: service_healthy
sushiswap-watcher-job-runner:
condition: service_healthy
image: cerc/watcher-sushiswap:local
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_ETH_RPC_ENDPOINTS: ${CERC_ETH_RPC_ENDPOINTS}
working_dir: /app/packages-watcher
command: ["bash", "./start-server.sh"]
volumes:
- ../config/watcher-sushiswap/watcher-config-template.toml:/app/packages-watcher/environments/watcher-config-template.toml
- ../config/common/start-server.sh:/app/packages-watcher/start-server.sh
- sushiswap_watcher_gql_logs_data:/app/packages-watcher/gql-logs
ports:
- "3008"
- "9001"
healthcheck:
test: ["CMD", "nc", "-vz", "127.0.0.1", "3008"]
interval: 20s
timeout: 5s
retries: 15
start_period: 5s
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
sushiswap_watcher_db_data:
sushiswap_watcher_gql_logs_data:

View File

@ -0,0 +1,104 @@
# SushiSwap Watcher
## Clone the stack repo
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/sushiswap-watcher-ts
```
## Build the container image
```bash
laconic-so --stack ~/cerc/sushiswap-watcher-ts/stacks/stack-orchestrator/stacks/sushiswap build-containers
```
## Create a spec file for the deployment
```bash
laconic-so --stack ~/cerc/sushiswap-watcher-ts/stacks/stack-orchestrator/stacks/sushiswap deploy init --output sushiswap-spec.yml
```
### Ports
Edit `network` in the spec file to map container ports to host ports as required:
```yml
...
network:
ports:
sushiswap-watcher-db:
- 15432:5432
sushiswap-watcher-job-runner:
- 9000:9000
sushiswap-watcher-server:
- 3008:3008
- 9001:9001
```
## Create a deployment from the spec file
```bash
laconic-so --stack ~/cerc/sushiswap-watcher-ts/stacks/stack-orchestrator/stacks/sushiswap deploy create --spec-file sushiswap-spec.yml --deployment-dir sushiswap-deployment
```
### Configuration
Inside deployment directory, open the `config.env` file and set following env variables:
```bash
# External Filecoin (ETH RPC) endpoint to point the watcher to
CERC_ETH_RPC_ENDPOINTS=https://example-lotus-endpoint-1/rpc/v1,https://example-lotus-endpoint-2/rpc/v1
```
## Start the deployment
```bash
laconic-so deployment --dir sushiswap-deployment start
```
* To list down and monitor the running containers:
```bash
# With status
docker ps -a
# Check logs for a container
docker logs -f <CONTAINER_ID>
```
* Open the GQL playground at <http://localhost:3008/graphql>
```graphql
# Example query
query {
_meta {
block {
hash
number
timestamp
}
deployment
hasIndexingErrors
}
```
## Clean up
Stop all the sushiswap services running in background:
```bash
# Only stop the docker containers
laconic-so deployment --dir sushiswap-deployment stop
# Run 'start' to restart the deployment
```
To stop all the sushiswap services and also delete data:
```bash
# Stop the docker containers
laconic-so deployment --dir sushiswap-deployment stop --delete-volumes
# Remove deployment directory (deployment will have to be recreated for a re-run)
rm -r sushiswap-deployment
```

View File

@ -0,0 +1,8 @@
version: "1.0"
name: sushiswap
description: "SushiSwap watcher stack"
repos:
containers:
- cerc/watcher-sushiswap
pods:
- watcher-sushiswap