Skip to content

Instantly share code, notes, and snippets.

@prestwich
Created November 15, 2022 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prestwich/1f90fb2d9bfc439f2075ce8679c3d305 to your computer and use it in GitHub Desktop.
Save prestwich/1f90fb2d9bfc439f2075ce8679c3d305 to your computer and use it in GitHub Desktop.
basic Eth2 docker script
GETH_NAME=geth
GETH_IMAGE=ethereum/client-go:latest
PRYSM_NAME=prysm
PRYSM_IMAGE=gcr.io/prysmaticlabs/prysm/beacon-chain:stable
# volumes for containers
STORAGE_LOCATION=~/eth/data
GETH_STORAGE=$STORAGE_LOCATION/geth
PRYSM_STORAGE=$STORAGE_LOCATION/prysm
SHARED_STORAGE=$STORAGE_LOCATION/shared
stop() {
if [ ! "$(docker ps -q -f name=$1)" ]; then
# clean up existing
echo "stopping and removing $1. This may take several minutes, as the container shuts down"
docker stop -t 120 $1
docker rm $1
fi
}
stop $GETH_NAME
stop $PRYSM_NAME
mkdir -p ~/eth/data
# doesn't matter if it fails
docker network create eth-node 2> /dev/null
set -e
# update
docker pull $GETH_IMAGE
docker pull $PRYSM_IMAGE
# run
echo "starting $GETH_NAME"
docker run -d \
-p 8545:8545 \
-p 8546:8546 \
-p 30303:30303 \
--net eth-nodes \
--name $GETH_NAME \
--restart unless-stopped \
-v $GETH_STORAGE:/data \
-v $SHARED_STORAGE:/shared \
$IMAGE_NAME \
--http --http.addr 0.0.0.0 \
--ws --ws.addr 0.0.0.0 \
--authrpc.addr 0.0.0.0 \
--authrpc.vhosts=* \
--authrpc.jwtsecret /shared/jwtsecret \
--datadir /data
echo "starting $PRYSM_NAME"
docker run -d \
-p 4000:4000 \
-p 12000:12000/udp \
-p 13000:13000 \
--net eth-nodes \
--name $CONTAINER_NAME \
--restart unless-stopped \
-v $PRYSM_STORAGE:/data \
-v $SHARED_STORAGE:/shared \
$IMAGE_NAME \
--accept-terms-of-use \
--datadir /data \
--rpc-host 0.0.0.0 --rpc-port 4000 \
--jwt-secret /shared/jwtsecret \
--execution-endpoint http://geth:8551 \
--checkpoint-sync-url https://beaconstate.ethstaker.cc/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment