Skip to content

Instantly share code, notes, and snippets.

@miohtama
Created January 25, 2023 23:51
Show Gist options
  • Save miohtama/dbbb19f36f0ce3ed8c3b7dca5952dfb4 to your computer and use it in GitHub Desktop.
Save miohtama/dbbb19f36f0ce3ed8c3b7dca5952dfb4 to your computer and use it in GitHub Desktop.
# Erigon modified compose.
#
# - Assumes data volume is mounted at /bsc
# - Txpool disabled
#
#
# Useful commands
# - logs: docker compose logs --follow erigon
#
# To start:
# # https://github.com/ledgerwatch/erigon/issues/3950
# chmod -R a+rwx /bsc/data/bsc-erigon
# docker-compose up -d
#
# Erigon by default is "all in one binary" solution, but it's possible start TxPool as separated processes.
# Same true about: JSON RPC layer (RPCDaemon), p2p layer (Sentry), history download layer (Downloader), consensus.
# Don't start services as separated processes unless you have clear reason for it: resource limiting, scale, replace by your own implementation, security.
# This file is an example: how to start Erigon's services as separated processes.
# Default: --datadir=/home/erigon/.local/share/erigon
# Default UID: 3473
# Default GID: 3473
# Ports: `9090` execution engine (private api), `9091` sentry, `9092` consensus engine, `9093` snapshot downloader, `9094` TxPool
# Ports: `8545` json rpc, `8551` consensus json rpc, `30303` eth p2p protocol, `42069` bittorrent protocol,
# Connections: erigon -> (sentries, downloader), rpcdaemon -> (erigon, txpool), txpool -> erigon
version: '2.3.1'
# Basic erigon's service
x-erigon-service: &default-erigon-service
image: tradingstrategy-ai/erigon:${TAG:-latest}
pid: service:erigon # Use erigon's PID namespace. It's required to open Erigon's DB from another process (RPCDaemon local-mode)
volumes_from: [ erigon ]
restart: unless-stopped
mem_swappiness: 0
user: ${DOCKER_UID:-1000}:${DOCKER_GID:-1000}
services:
erigon:
image: tradingstrategy-ai/erigon:${TAG:-latest}
build:
args:
UID: ${DOCKER_UID:-1000}
GID: ${DOCKER_GID:-1000}
context: .
# Because we are inside Docker we bind 0.0.0.0,
# and these ports are then managed by Caddy reverse proxy
# on the host.
# We prune historical state and call traces,
# making this GoEthereum "full node" compatible with full receipt history
# see discussion https://github.com/ledgerwatch/erigon/discussions/6612
command: |
erigon ${ERIGON_FLAGS-}
--private.api.addr=0.0.0.0:9090
--sentry.api.addr=sentry:9091
--downloader.api.addr=downloader:9093
--txpool.disable
--networkid 56
--nat any
--chain=bsc
--metrics
--metrics.addr=0.0.0.0
--metrics.port=6060
--pprof
--pprof.addr=0.0.0.0
--pprof.port=6061
--authrpc.jwtsecret=/home/erigon/.local/share/erigon/jwt.hex --datadir=/home/erigon/.local/share/erigon
--prune hc
ports: [ "127.0.0.1:8551:8551" ]
volumes:
# It's ok to mount sub-dirs of "datadir" to different drives
#- ${XDG_DATA_HOME:-~/.local/share}/erigon:/home/erigon/.local/share/erigon
- /bsc/data/bsc-erigon:/home/erigon/.local/share/erigon
restart: unless-stopped
mem_swappiness: 0
sentry:
<<: *default-erigon-service
command: sentry ${SENTRY_FLAGS-} --sentry.api.addr=0.0.0.0:9091 --datadir=/home/erigon/.local/share/erigon
ports: [ "30303:30303/tcp", "30303:30303/udp" ]
downloader:
<<: *default-erigon-service
command: downloader ${DOWNLOADER_FLAGS-} --downloader.api.addr=0.0.0.0:9093 --datadir=/home/erigon/.local/share/erigon
ports: [ "42069:42069/tcp", "42069:42069/udp" ]
# txpool:
# <<: *default-erigon-service
# command: txpool ${TXPOOL_FLAGS-} --private.api.addr=erigon:9090 --txpool.api.addr=0.0.0.0:9094 --sentry.api.addr=sentry:9091 --datadir=/home/erigon/.local/share/erigon
# Bind to localhost 8545 so that the port can be reverse proxied/password protected with Caddy
rpcdaemon:
<<: *default-erigon-service
command: |
rpcdaemon ${RPCDAEMON_FLAGS-} --http.addr=0.0.0.0 --http.vhosts=* --http.corsdomain=* --ws
--private.api.addr=erigon:9090 --txpool.api.addr=txpool:9094 --datadir=/home/erigon/.local/share/erigon --log.console.verbosity 4 --http.api=eth,erigon,web3,net,debug,trace,txpool
ports: [ "127.0.0.1:8545:8545" ]
prometheus:
image: prom/prometheus:v2.40.4
user: ${DOCKER_UID:-1000}:${DOCKER_GID:-1000} # Uses erigon user from Dockerfile
command: --log.level=warn --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus --storage.tsdb.retention.time=150d --web.console.libraries=/usr/share/prometheus/console_libraries --web.console.templates=/usr/share/prometheus/consoles
ports: [ "127.0.0.1:9090:9090" ]
volumes:
# - ${ERIGON_PROMETHEUS_CONFIG:-./cmd/prometheus/prometheus.yml}:/etc/prometheus/prometheus.yml
- /bsc/data/monitor/cmd/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- /bsc/data/monitor/erigon-prometheus:/prometheus
# - ${XDG_DATA_HOME:-~/.local/share}/erigon-prometheus:/prometheus
restart: unless-stopped
grafana:
image: grafana/grafana:9.3.0
user: "472:0" # required for grafana version >= 7.3
ports: [ "127.0.0.1:3000:3000" ]
volumes:
# - ${ERIGON_GRAFANA_CONFIG:-./cmd/prometheus/grafana.ini}:/etc/grafana/grafana.ini
- /bsc/data/monitor/cmd/prometheus/grafana.ini:/etc/grafana/grafana.ini
- /bsc/data/monitor/cmd/prometheus/datasources:/etc/grafana/provisioning/datasources
- /bsc/data/monitor/cmd/prometheus/dashboards:/etc/grafana/provisioning/dashboards
- /bsc/data/monitor/erigon-grafana:/var/lib/grafana
# - ${XDG_DATA_HOME:-~/.local/share}/erigon-grafana:/var/lib/grafana
restart: unless-stopped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment