mirror of
				https://github.com/grassrootseconomics/cic-chain-events.git
				synced 2025-11-04 09:28:22 +01:00 
			
		
		
		
	devops: add deploy
This commit is contained in:
		
							parent
							
								
									487b998347
								
							
						
					
					
						commit
						54e54eeb61
					
				
							
								
								
									
										19
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								README.md
									
									
									
									
									
								
							@ -1,18 +1,13 @@
 | 
			
		||||
# 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
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										41
									
								
								deploy/benthos.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								deploy/benthos.yaml
									
									
									
									
									
										Normal file
									
								
							@ -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
 | 
			
		||||
							
								
								
									
										51
									
								
								deploy/docker-compose.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								deploy/docker-compose.yaml
									
									
									
									
									
										Normal file
									
								
							@ -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    
 | 
			
		||||
							
								
								
									
										8
									
								
								deploy/events.env
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								deploy/events.env
									
									
									
									
									
										Normal file
									
								
							@ -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
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user