From 54e54eeb61379e8adba7def2fe23081faecb04cb Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Tue, 15 Aug 2023 18:26:24 +0800 Subject: [PATCH] devops: add deploy --- README.md | 19 ++++++-------- deploy/benthos.yaml | 41 ++++++++++++++++++++++++++++++ deploy/docker-compose.yaml | 51 ++++++++++++++++++++++++++++++++++++++ deploy/events.env | 8 ++++++ 4 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 deploy/benthos.yaml create mode 100644 deploy/docker-compose.yaml create mode 100644 deploy/events.env diff --git a/README.md b/README.md index c7d6884..a61afb7 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,13 @@ # cic-chain-events -![GitHub release (latest by date)](https://img.shields.io/github/v/release/inethi/inethi-cic-chain-events) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/inethi/inethi-cic-chain-events/release.yaml) [![Go Report Card](https://goreportcard.com/badge/github.com/inethi/inethi-cic-chain-events)](https://goreportcard.com/report/github.com/inethi/inethi-cic-chain-events) -> CIC Chain Events +## Usage -Filters live (and past) transactions on Celo and emits relevant events to a NATS JetStream sink for further processing/indexing. - -## Documentation - -- [Functionality](docs/functionality.md) -- [Usage](docs/usage.md) - -## License - -[AGPL-3.0](LICENSE). +```sh +$ git clone https://github.com/iNethi/inethi-cic-chain-events.git +$ cd deploy +# Update the values in events.env and benthos.yaml +$ docker-compose up +``` diff --git a/deploy/benthos.yaml b/deploy/benthos.yaml new file mode 100644 index 0000000..40c4a0d --- /dev/null +++ b/deploy/benthos.yaml @@ -0,0 +1,41 @@ +input: + label: cic_chain_events + nats_jetstream: + urls: + - nats://localhost:4222 + subject: CHAIN.transfer + durable: benthos_sub + stream: CHAIN + deliver: all +pipeline: + processors: + - label: event_transformer + bloblang: | + root = this + root.timestamp = (this.timestamp).ts_format() + root.txType = if this.txType == "transfer" { + "TRANSFER" + } else if this.txType == "mintTo" { + "MINT_TO" + } else { + "TRANSFER_FROM" + } +output: + broker: + outputs: + - label: webhooks + http_client: + # To be updated to a secure endpoint + url: "https://webhook.site/ab61ace1-52bf-4495-a11a-4630a2a7cb6f" + verb: POST + timeout: 5s + - label: logg + stdout: + codec: lines + +logger: + level: DEBUG + format: logfmt + add_timestamp: false + static_fields: + '@service': benthos \ No newline at end of file diff --git a/deploy/docker-compose.yaml b/deploy/docker-compose.yaml new file mode 100644 index 0000000..f5c1cde --- /dev/null +++ b/deploy/docker-compose.yaml @@ -0,0 +1,51 @@ +version: '3.9' +services: + postgres: + image: postgres:14-alpine + restart: unless-stopped + user: postgres + environment: + - POSTGRES_PASSWORD=postgres + - POSTGRES_USER=postgres + - POSTGRES_DB=cic_chain_events + volumes: + - cic-indexer-pg:/var/lib/postgresql/data + ports: + - '5432:5432' + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 + nats: + image: nats:2.9 + restart: unless-stopped + command: "-js -sd /nats/data" + volumes: + - cic-indexer-nats:/nats/data + ports: + - '4222:4222' + - '8222:8222' + cic-chain-events: + image: ghcr.io/inethi/inethi-cic-chain-events/cic-chain-events:v0.1.0 + restart: unless-stopped + depends_on: + postgres: + condition: service_healthy + nats: + condition: service_started + env_file: + - events.env + benthos: + image: jeffail/benthos:4 + restart: unless-stopped + depends_on: + nats: + condition: service_started + volumes: + - ./benthos.yaml:/benthos.yaml +volumes: + cic-indexer-pg: + driver: local + cic-indexer-nats: + driver: local \ No newline at end of file diff --git a/deploy/events.env b/deploy/events.env new file mode 100644 index 0000000..d07a69c --- /dev/null +++ b/deploy/events.env @@ -0,0 +1,8 @@ +EVENTS_CHAIN__GRAPHQL_ENDPOINT=https://celo.grassecon.net/graphql +EVENTS_CHAIN__WS_ENDPOINT=wss://ws.celo.grassecon.net +EVENTS_CHAIN__RPC_ENDPOINT=https://celo.grassecon.net +EVENTS_CHAIN__TESTNET=false +# uUdate below to the latest block (celoscan.io) +EVENTS_SYNCER__INITIAL_LOWER_BOUND= +EVENTS_POSTGRES__DSN=postgres://postgres:postgres@postgres:5432/cic_chain_events +EVENTS_JETSTREAM__ENDPOINT=nats://nats:4222 \ No newline at end of file