Skip to content

Commit 69e4edd

Browse files
authored
Merge pull request #13 from migalabs/feat/docker-run-commands-from-sh
Feat/docker run commands from sh
2 parents a40372a + 446f321 commit 69e4edd

File tree

5 files changed

+36
-24
lines changed

5 files changed

+36
-24
lines changed

.env.example

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
LOG_LEVEL="info" # debug, info, warn, error
1+
LOG_LEVEL="info" # debug, info, warn, error
2+
WORKER_NUM=10 # Number of workers to run concurrent alchemy/EL node requests
3+
WHALE_THRESHOLD=100 # Threshold for whale detection (min amount of validators)
4+
5+
# UPDATE THESE VALUES
26
DB_URL="postgres://user:password@localhost:5432/dbName" # URL to connect to the postgres database
3-
WORKER_NUM=15 # Number of workers to run concurrent alchemy/EL node requests
47
ALCHEMY_URL="https://eth-mainnet.g.alchemy.com/v2/KEY" # Alchemy API URL
58
EL_ENDPOINT="http://localhost:8545" # Ethereum Layer 1 endpoint, can also be alchemy or infura
6-
WHALE_THRESHOLD=100 # Threshold for whale detection (min amount of validators)
79

810
DATABASE_NAME=name # Your database name
911
DATABASE_USERNAME=user # Your database username

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ ADD . .
66
RUN go get
77
RUN go build -o ./build/eth_pokhar
88

9-
109
FROM alpine:latest
1110
WORKDIR /
1211
COPY --from=builder /app/build/eth_pokhar ./
1312
COPY --from=builder /app/db/migrations ./db/migrations
14-
15-
ENTRYPOINT ["sh", "-c"]
13+
COPY --from=builder /app/run.sh ./run.sh
14+
RUN chmod +x ./run.sh
15+
ENTRYPOINT [ "./eth_pokhar" ]

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ OPTIONS:
6363
--help, -h show help
6464
```
6565

66-
## Running with Docker (recommended)
66+
## Running with docker-compose (recommended)
6767

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

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

84+
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:
85+
86+
```bash
87+
ONLY_DEPOSITS=true docker-compose up -d
88+
```
89+
90+
This will set the [`--only-deposits`](#beacon_depositors_transactions) flag to true.
91+
8492
## Output
8593

8694
The tool will create a database with the following tables:

docker-compose.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,14 @@ services:
66
context: ./
77
dockerfile: Dockerfile
88
init: true
9-
command: >-
10-
"
11-
./eth_pokhar beacon_depositors_transactions
12-
--log-level=${LOG_LEVEL}
13-
--el-endpoint=${EL_ENDPOINT}
14-
--db-url=${DB_URL}
15-
--workers-num=${WORKER_NUM}
16-
--alchemy-url=${ALCHEMY_URL}
17-
&&
18-
./eth_pokhar identify
19-
--log-level=${LOG_LEVEL}
20-
--el-endpoint=${EL_ENDPOINT}
21-
--db-url=${DB_URL}
22-
--workers-num=${WORKER_NUM}
23-
--alchemy-url=${ALCHEMY_URL}
24-
--recreate-table"
25-
--whale-threshold=${WHALE_THRESHOLD}
9+
environment:
10+
- LOG_LEVEL=${LOG_LEVEL}
11+
- EL_ENDPOINT=${EL_ENDPOINT}
12+
- DB_URL=${DB_URL}
13+
- WORKER_NUM=${WORKER_NUM}
14+
- ALCHEMY_URL=${ALCHEMY_URL}
15+
- WHALE_THRESHOLD=${WHALE_THRESHOLD}
16+
- ONLY_DEPOSITS=${ONLY_DEPOSITS:-false}
2617
network_mode: "host"
2718
depends_on:
2819
db:
@@ -31,6 +22,7 @@ services:
3122
restart_policy:
3223
condition: on-failure
3324
max_attempts: 5
25+
entrypoint: ["sh", "./run.sh"]
3426

3527
db:
3628
image: postgres

run.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# If ONLY_DEPOSITS is true then use --only-deposits flag, else use the default
4+
if [ "${ONLY_DEPOSITS}" = "true" ]; then
5+
./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
6+
else
7+
./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
8+
fi
9+
10+
./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

0 commit comments

Comments
 (0)