From fb22f26e18838696c1e9a4a1ebcd114da06ff5b5 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Mon, 10 Jun 2024 15:45:43 +0800 Subject: [PATCH] feat: metrics port update -> :5002 --- Dockerfile | 2 +- README.md | 61 ++++++++++++++++++++++++++++++++ config.toml | 2 +- dev/docker-compose.postgres.yaml | 22 ++++++++++++ dev/docker-compose.yaml | 19 +++++++--- 5 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 README.md create mode 100644 dev/docker-compose.postgres.yaml diff --git a/Dockerfile b/Dockerfile index 13e07d9..93986a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,6 @@ WORKDIR /service COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=build /build/* . -EXPOSE 5001 +EXPOSE 5002 CMD ["./celo-indexer"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..42c1fdb --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +# celo-indexer + +![GitHub Tag](https://img.shields.io/github/v/tag/grassrootseconomics/celo-indexer) + +A lightweight Postgres chain indexer designed to couple with [celo-tracker](https://github.com/grassrootseconomics/celo-tracker) to index all relevant GE related blockchain data on the Celo blockchain. + +## Getting Started + +### Prerequisites + +* Git +* Docker +* Postgres server +* Access to a `celo-tracker` instance + +See [docker-compose.yaml](dev/docker-compose.yaml) for an example on how to run and deploy a single instance. + +### 1. Build the Docker image + +We provide pre-built images for `linux/amd64`. See the packages tab on Github. + +If you are on any other platform: + +```bash +git clone https://github.com/grassrootseconomics/celo-indexer.git +cd celo-indexer +docker buildx build --build-arg BUILD=$(git rev-parse --short HEAD) --tag celo-indexer:$(git rev-parse --short HEAD) --tag celo-indexer:latest . +docker images +``` + +### 2. Run Postgres + +For an example, see `dev/docker-compose.postgres.yaml`. + +### 3. Update config values + +See `.env.example` on how to override default values defined in `config.toml` using env variables. Alternatively, mount your own config.toml either during build time or Docker runtime. + +```bash +# Override only specific config values +nano .env.example +mv .env.example .env +``` + +Special env variables: + +* DEV=* + +Refer to [`config.toml`](config.toml) to understand different config value settings. + + +### 4. Run the indexer + +```bash +cd dev +docker compose up +``` + +## License + +[AGPL-3.0](LICENSE). \ No newline at end of file diff --git a/config.toml b/config.toml index 2096fe3..787c068 100644 --- a/config.toml +++ b/config.toml @@ -2,7 +2,7 @@ go_process = true [api] -address = ":5001" +address = ":5002" [postgres] dsn = "postgres://postgres:postgres@127.0.0.1:5432/ge_celo_data" diff --git a/dev/docker-compose.postgres.yaml b/dev/docker-compose.postgres.yaml new file mode 100644 index 0000000..be9ebec --- /dev/null +++ b/dev/docker-compose.postgres.yaml @@ -0,0 +1,22 @@ +services: + postgres: + image: postgres:16-alpine + restart: unless-stopped + user: postgres + environment: + - POSTGRES_PASSWORD=postgres + - POSTGRES_USER=postgres + volumes: + - ./init_db.sql:/docker-entrypoint-initdb.d/init_db.sql + - indexer-pg:/var/lib/postgresql/data + ports: + - "127.0.0.1:5432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + indexer-pg: + driver: local \ No newline at end of file diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index be9ebec..70b48d1 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -8,15 +8,26 @@ services: - POSTGRES_USER=postgres volumes: - ./init_db.sql:/docker-entrypoint-initdb.d/init_db.sql - - indexer-pg:/var/lib/postgresql/data + - celo-indexer-pg:/var/lib/postgresql/data ports: - "127.0.0.1:5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready"] interval: 10s timeout: 5s - retries: 5 - + retries: 5 + celo-indexer: + image: celo-indexer:latest + restart: unless-stopped + depends_on: + postgres: + condition: service_healthy + environment: + # Point to the correct celo-tracker JetStream instance + - INDEXER_JETSTREAM__ENDPOINT=nats://nats:4222 + ports: + - 127.0.0.1:5002:5002 + volumes: - indexer-pg: + celo-indexer-pg: driver: local \ No newline at end of file