Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/docker run commands from sh #13

Merged
merged 8 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
LOG_LEVEL="info" # debug, info, warn, error
LOG_LEVEL="info" # debug, info, warn, error
WORKER_NUM=10 # Number of workers to run concurrent alchemy/EL node requests
WHALE_THRESHOLD=100 # Threshold for whale detection (min amount of validators)

# UPDATE THESE VALUES
DB_URL="postgres://user:password@localhost:5432/dbName" # URL to connect to the postgres database
WORKER_NUM=15 # Number of workers to run concurrent alchemy/EL node requests
ALCHEMY_URL="https://eth-mainnet.g.alchemy.com/v2/KEY" # Alchemy API URL
EL_ENDPOINT="http://localhost:8545" # Ethereum Layer 1 endpoint, can also be alchemy or infura
WHALE_THRESHOLD=100 # Threshold for whale detection (min amount of validators)

DATABASE_NAME=name # Your database name
DATABASE_USERNAME=user # Your database username
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ ADD . .
RUN go get
RUN go build -o ./build/eth_pokhar


FROM alpine:latest
WORKDIR /
COPY --from=builder /app/build/eth_pokhar ./
COPY --from=builder /app/db/migrations ./db/migrations

ENTRYPOINT ["sh", "-c"]
COPY --from=builder /app/run.sh ./run.sh
RUN chmod +x ./run.sh
ENTRYPOINT [ "./eth_pokhar" ]
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ OPTIONS:
--help, -h show help
```

## Running with Docker (recommended)
## Running with docker-compose (recommended)

To run the tool with docker, you can use the following commands:

Expand All @@ -81,6 +81,14 @@ Finally, run the tool with the following command:
docker-compose up -d
```

In case that you don't want to update de depositor transactions (which can take up to 20 hours), you can set `ONLY_DEPOSITS=true` in the `.env` file and run the tool normally or use the following command:

```bash
ONLY_DEPOSITS=true docker-compose up -d
santi1234567 marked this conversation as resolved.
Show resolved Hide resolved
```

This will set the [`--only-deposits`](#beacon_depositors_transactions) flag to true.

## Output

The tool will create a database with the following tables:
Expand Down
26 changes: 9 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,14 @@ services:
context: ./
dockerfile: Dockerfile
init: true
command: >-
"
./eth_pokhar beacon_depositors_transactions
--log-level=${LOG_LEVEL}
--el-endpoint=${EL_ENDPOINT}
--db-url=${DB_URL}
--workers-num=${WORKER_NUM}
--alchemy-url=${ALCHEMY_URL}
&&
./eth_pokhar identify
--log-level=${LOG_LEVEL}
--el-endpoint=${EL_ENDPOINT}
--db-url=${DB_URL}
--workers-num=${WORKER_NUM}
--alchemy-url=${ALCHEMY_URL}
--recreate-table"
--whale-threshold=${WHALE_THRESHOLD}
environment:
- LOG_LEVEL=${LOG_LEVEL}
- EL_ENDPOINT=${EL_ENDPOINT}
- DB_URL=${DB_URL}
- WORKER_NUM=${WORKER_NUM}
- ALCHEMY_URL=${ALCHEMY_URL}
- WHALE_THRESHOLD=${WHALE_THRESHOLD}
- ONLY_DEPOSITS=${ONLY_DEPOSITS:-false}
network_mode: "host"
depends_on:
db:
Expand All @@ -31,6 +22,7 @@ services:
restart_policy:
condition: on-failure
max_attempts: 5
entrypoint: ["sh", "./run.sh"]

db:
image: postgres
Expand Down
10 changes: 10 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# If ONLY_DEPOSITS is true then use --only-deposits flag, else use the default
if [ "${ONLY_DEPOSITS}" = "true" ]; then
./eth_pokhar beacon_depositors_transactions --log-level=${LOG_LEVEL} --el-endpoint=${EL_ENDPOINT} --db-url=${DB_URL} --workers-num=${WORKER_NUM} --alchemy-url=${ALCHEMY_URL} --only-deposits || exit 1
else
./eth_pokhar beacon_depositors_transactions --log-level=${LOG_LEVEL} --el-endpoint=${EL_ENDPOINT} --db-url=${DB_URL} --workers-num=${WORKER_NUM} --alchemy-url=${ALCHEMY_URL} || exit 1
fi

./eth_pokhar identify --log-level=${LOG_LEVEL} --el-endpoint=${EL_ENDPOINT} --db-url=${DB_URL} --workers-num=${WORKER_NUM} --alchemy-url=${ALCHEMY_URL} --recreate-table --whale-threshold=${WHALE_THRESHOLD} || exit 1