mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add docker compose with docs (#3496)
Co-authored-by: Oliver Nordbjerg <hi@notbjerg.me>
This commit is contained in:
committed by
GitHub
parent
770652a787
commit
da58e39c26
@ -45,3 +45,74 @@ The build will likely take several minutes. Once it's built, test it with:
|
|||||||
```bash
|
```bash
|
||||||
docker run reth:local --version
|
docker run reth:local --version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Using the Docker image
|
||||||
|
|
||||||
|
There are two ways to use the Docker image:
|
||||||
|
1. [Using Docker](#using-plain-docker)
|
||||||
|
2. [Using Docker Compose](#using-docker-compose)
|
||||||
|
|
||||||
|
### Using Plain Docker
|
||||||
|
|
||||||
|
To run Reth with Docker, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run \
|
||||||
|
-v rethdata:/root/.local/share/reth/db \
|
||||||
|
-d \
|
||||||
|
-p 9000:9000 \
|
||||||
|
--name reth \
|
||||||
|
reth:local \
|
||||||
|
node \
|
||||||
|
--metrics 0.0.0.0:9000
|
||||||
|
```
|
||||||
|
|
||||||
|
The above command will create a container named `reth` and a named volume called `rethdata` for data persistence.
|
||||||
|
|
||||||
|
It will use the local image `reth:local`. If you want to use the GitHub Container Registry remote image, use `ghcr.io/paradigmxyz/reth` with your preferred tag.
|
||||||
|
|
||||||
|
### Using Docker Compose
|
||||||
|
|
||||||
|
To run Reth with Docker Compose, run the following command from a shell inside the root directory of this repository:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./etc/generate-jwt.sh
|
||||||
|
docker compose -f etc/docker-compose.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
To check if Reth is running correctly, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose logs -f reth
|
||||||
|
```
|
||||||
|
|
||||||
|
The default `docker-compose.yml` file will create four containers:
|
||||||
|
|
||||||
|
- Reth
|
||||||
|
- Prometheus
|
||||||
|
- Grafana
|
||||||
|
- Lighthouse
|
||||||
|
|
||||||
|
Grafana will be exposed on `localhost:3000` and accessible via default credentials (username and password is `admin`)
|
||||||
|
|
||||||
|
## Interacting with Reth inside Docker
|
||||||
|
|
||||||
|
To interact with Reth you must first open a shell inside the Reth container by running:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -it reth bash
|
||||||
|
```
|
||||||
|
|
||||||
|
**If Reth is running with Docker Compose, replace `reth` with `reth-reth-1` in the above command**
|
||||||
|
|
||||||
|
### Listing the tables
|
||||||
|
|
||||||
|
```bash
|
||||||
|
reth db stats
|
||||||
|
```
|
||||||
|
|
||||||
|
### Viewing some records
|
||||||
|
|
||||||
|
```bash
|
||||||
|
reth db list --start=1 --len=2 Headers
|
||||||
|
```
|
||||||
1
etc/.gitignore
vendored
Normal file
1
etc/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
jwttoken
|
||||||
@ -11,14 +11,4 @@ The files in this directory may undergo a lot of changes while reth is unstable,
|
|||||||
|
|
||||||
### Docker Compose
|
### Docker Compose
|
||||||
|
|
||||||
To run Grafana dashboard with example dashboard and pre-configured Prometheus data source pointing at
|
To run Reth, Grafana and Prometheus with Docker Compose, refer to the [docker docs](/book/installation/docker.md#using-docker-compose)
|
||||||
the locally running Reth instance with metrics exposed on `localhost:9001`:
|
|
||||||
```sh
|
|
||||||
docker compose -p reth -f ./etc/docker-monitoring.yml up
|
|
||||||
```
|
|
||||||
|
|
||||||
After that, Grafana will be exposed on `localhost:3000` and accessible via default credentials:
|
|
||||||
```
|
|
||||||
username: admin
|
|
||||||
password: admin
|
|
||||||
```
|
|
||||||
95
etc/docker-compose.yml
Normal file
95
etc/docker-compose.yml
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
version: '3.9'
|
||||||
|
name: 'reth'
|
||||||
|
|
||||||
|
services:
|
||||||
|
reth:
|
||||||
|
restart: unless-stopped
|
||||||
|
image: ghcr.io/paradigmxyz/reth
|
||||||
|
ports:
|
||||||
|
- '9001:9001' # metrics
|
||||||
|
- '30303:30303' # eth/66 peering
|
||||||
|
- '8545:8545' # rpc
|
||||||
|
volumes:
|
||||||
|
- rethdata:/root/.local/share/reth/mainnet/db
|
||||||
|
- rethlogs:/root/rethlogs
|
||||||
|
- ./jwttoken:/root/jwt:ro
|
||||||
|
command: >
|
||||||
|
node
|
||||||
|
--metrics 0.0.0.0:9001
|
||||||
|
--log.persistent
|
||||||
|
--log.directory /root/rethlogs
|
||||||
|
--authrpc.addr 0.0.0.0
|
||||||
|
--authrpc.port 8551
|
||||||
|
--authrpc.jwtsecret /root/jwt/jwt.hex
|
||||||
|
--http --http.addr 0.0.0.0 --http.port 8545
|
||||||
|
--http.api "eth,net"
|
||||||
|
|
||||||
|
lighthouse:
|
||||||
|
restart: unless-stopped
|
||||||
|
image: sigp/lighthouse
|
||||||
|
depends_on:
|
||||||
|
- reth
|
||||||
|
ports:
|
||||||
|
- '5052:5052/tcp'
|
||||||
|
- '5053:5053/tcp'
|
||||||
|
- '5054:5054/tcp' # metrics
|
||||||
|
- '9000:9000/tcp'
|
||||||
|
- '9000:9000/udp'
|
||||||
|
volumes:
|
||||||
|
- lighthousedata:/root/.lighthouse
|
||||||
|
- ./jwttoken:/root/jwt:ro
|
||||||
|
command: >
|
||||||
|
lighthouse bn
|
||||||
|
--http --http-address 0.0.0.0
|
||||||
|
--execution-endpoint http://reth:8551
|
||||||
|
--metrics --metrics-address 0.0.0.0
|
||||||
|
--execution-jwt /root/jwt/jwt.hex
|
||||||
|
--checkpoint-sync-url https://mainnet.checkpoint.sigp.io
|
||||||
|
|
||||||
|
prometheus:
|
||||||
|
restart: unless-stopped
|
||||||
|
image: prom/prometheus
|
||||||
|
depends_on:
|
||||||
|
- reth
|
||||||
|
ports:
|
||||||
|
- 9090:9090
|
||||||
|
volumes:
|
||||||
|
- ./prometheus/:/etc/prometheus/
|
||||||
|
- prometheusdata:/prometheus
|
||||||
|
command:
|
||||||
|
- --config.file=/etc/prometheus/prometheus.yml
|
||||||
|
- --storage.tsdb.path=/prometheus
|
||||||
|
|
||||||
|
grafana:
|
||||||
|
restart: unless-stopped
|
||||||
|
image: grafana/grafana
|
||||||
|
depends_on:
|
||||||
|
- reth
|
||||||
|
- prometheus
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
environment:
|
||||||
|
PROMETHEUS_URL: http://prometheus:9090
|
||||||
|
volumes:
|
||||||
|
- grafanadata:/var/lib/grafana
|
||||||
|
- ./grafana/datasources:/etc/grafana/provisioning/datasources
|
||||||
|
- ./grafana/dashboards:/etc/grafana/provisioning_temp/dashboards
|
||||||
|
# 1. Copy dashboards from temp directory to prevent modifying original host files
|
||||||
|
# 2. Replace Prometheus datasource placeholder with the actual name
|
||||||
|
# 3. Run Grafana
|
||||||
|
entrypoint: >
|
||||||
|
sh -c "cp -r /etc/grafana/provisioning_temp/dashboards/. /etc/grafana/provisioning/dashboards &&
|
||||||
|
find /etc/grafana/provisioning/dashboards/ -name '*.json' -exec sed -i 's/$${DS_PROMETHEUS}/Prometheus/g' {} \+ &&
|
||||||
|
/run.sh"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
rethdata:
|
||||||
|
driver: local
|
||||||
|
rethlogs:
|
||||||
|
driver: local
|
||||||
|
lighthousedata:
|
||||||
|
driver: local
|
||||||
|
prometheusdata:
|
||||||
|
driver: local
|
||||||
|
grafanadata:
|
||||||
|
driver: local
|
||||||
@ -1,39 +0,0 @@
|
|||||||
version: '3'
|
|
||||||
|
|
||||||
services:
|
|
||||||
prometheus:
|
|
||||||
image: prom/prometheus
|
|
||||||
ports:
|
|
||||||
- 9090:9090
|
|
||||||
volumes:
|
|
||||||
- ./prometheus/:/etc/prometheus/
|
|
||||||
- prometheus_data:/prometheus
|
|
||||||
command:
|
|
||||||
- --config.file=/etc/prometheus/prometheus.yml
|
|
||||||
- --storage.tsdb.path=/prometheus
|
|
||||||
extra_hosts:
|
|
||||||
- "host.docker.internal:host-gateway" # https://stackoverflow.com/a/43541732/5204678
|
|
||||||
|
|
||||||
grafana:
|
|
||||||
image: grafana/grafana
|
|
||||||
ports:
|
|
||||||
- 3000:3000
|
|
||||||
environment:
|
|
||||||
PROMETHEUS_URL: http://prometheus:9090
|
|
||||||
# 1. Copy dashboards from temp directory to prevent modifying original host files
|
|
||||||
# 2. Replace Prometheus datasource placeholder with the actual name
|
|
||||||
# 3. Run Grafana
|
|
||||||
entrypoint: >
|
|
||||||
sh -c "cp -r /etc/grafana/provisioning_temp/dashboards/. /etc/grafana/provisioning/dashboards &&
|
|
||||||
find /etc/grafana/provisioning/dashboards/ -name '*.json' -exec sed -i 's/$${DS_PROMETHEUS}/Prometheus/g' {} \+ &&
|
|
||||||
/run.sh"
|
|
||||||
volumes:
|
|
||||||
- grafana_data:/var/lib/grafana
|
|
||||||
- ./grafana/datasources:/etc/grafana/provisioning/datasources
|
|
||||||
- ./grafana/dashboards:/etc/grafana/provisioning_temp/dashboards
|
|
||||||
depends_on:
|
|
||||||
- prometheus
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
prometheus_data:
|
|
||||||
grafana_data:
|
|
||||||
4
etc/generate-jwt.sh
Executable file
4
etc/generate-jwt.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
# Borrowed from EthStaker's prepare for the merge guide
|
||||||
|
# See https://github.com/remyroy/ethstaker/blob/main/prepare-for-the-merge.md#configuring-a-jwt-token-file
|
||||||
|
mkdir -p jwttoken
|
||||||
|
openssl rand -hex 32 | tr -d "\n" | tee > jwttoken/jwt.hex
|
||||||
@ -3,4 +3,4 @@ scrape_configs:
|
|||||||
metrics_path: "/"
|
metrics_path: "/"
|
||||||
scrape_interval: 5s
|
scrape_interval: 5s
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: ['localhost:9001', 'host.docker.internal:9001']
|
- targets: ['reth:9001']
|
||||||
Reference in New Issue
Block a user