From fa89b4822f2965992792109893d75195c338fc7d Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Mon, 27 May 2024 18:29:48 +0800 Subject: [PATCH] dev: add improved example, change db directory --- .gitignore | 1 + README.md | 8 +++----- dev/docker-compose.nats.yaml | 9 +++++++++ dev/docker-compose.yaml | 26 +++++++++++++++++++++++--- internal/db/bolt.go | 2 +- 5 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 dev/docker-compose.nats.yaml diff --git a/.gitignore b/.gitignore index 36a5bea..ed43cd2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ tracker_db +db .vscode .idx \ No newline at end of file diff --git a/README.md b/README.md index bd1f8d0..986973f 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ It applies deduplication at the NATS level, making it safe to run in a distribut * NATS server * Access to a Celo RPC node +See [docker-compose.yaml](dev/docker-compose.yaml) for an example on how to run a deploy a single instance. + ### 1. Build the Docker image We provide pre-built images for `linux/amd64`. See the packages tab on Github. @@ -30,11 +32,7 @@ docker images ### 2. Run NATS -```bash -cd dev -docker compose up -d -docker ps -``` +For an example, see `dev/docker-compose.nats.yaml`. ### 3. Update config values diff --git a/dev/docker-compose.nats.yaml b/dev/docker-compose.nats.yaml new file mode 100644 index 0000000..93de71f --- /dev/null +++ b/dev/docker-compose.nats.yaml @@ -0,0 +1,9 @@ +services: + nats: + image: nats:2 + restart: unless-stopped + command: -js -sd /tmp/nats/data -m 8222 + ports: + - 0.0.0.0:4222:4222 + - 0.0.0.0:8222:8222 + \ No newline at end of file diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index e456040..096e209 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -2,7 +2,27 @@ services: nats: image: nats:2 restart: unless-stopped - command: -js -sd /tmp/nats/data -m 8222 + command: -js -sd /nats/data -m 8222 ports: - - 0.0.0.0:4222:4222 - - 0.0.0.0:8222:8222 \ No newline at end of file + - 127.0.0.1:4222:4222 + - 127.0.0.1:8222:8222 + volumes: + - celo-tracker-nats:/nats/data + celo-tracker: + image: celo-tracker:latest + restart: unless-stopped + depends_on: + - nats + environment: + - DEV=true + - TRACKER_JETSTREAM__ENDPOINT=nats://nats:4222 + ports: + - 127.0.0.1:5001:5001 + volumes: + - celo-tracker-db:/service/db + +volumes: + celo-tracker-nats: + driver: local + celo-tracker-db: + driver: local \ No newline at end of file diff --git a/internal/db/bolt.go b/internal/db/bolt.go index 5464c23..6168bf0 100644 --- a/internal/db/bolt.go +++ b/internal/db/bolt.go @@ -14,7 +14,7 @@ type boltDB struct { } const ( - dbFolderName = "tracker_db" + dbFolderName = "db/tracker_db" upperBoundKey = "upper" lowerBoundKey = "lower"