diff --git a/.gitignore b/.gitignore index 2e4c595..169e1d9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /target /run.sh -data \ No newline at end of file +data +redis-data \ No newline at end of file diff --git a/README.md b/README.md index c006797..4347d5c 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,10 @@ A simple http server to cache specific eth rpc requests in memory. Useful for ma Multiple endpoints/chains can be configured to be cached. ### Usage (with docker) -```shell -docker run \ - -d \ - -p 8124:8124 \ - -v ./data/:/data/ \ - -e DATA_PERSISTENCE=1 \ - -e ENDPOINTS="eth-chain=https://rpc.ankr.com/eth,bsc-chain=https://rpc.ankr.com/bsc" \ - --name cached-eth-rpc \ - ghcr.io/tonyke-bot/cached-eth-rpc -``` +1. Edit `docker-compose.yml` + +2. `docker-compose up` ### Usage With ```shell diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..675946b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3" +services: + docker-redis: + image: redis:alpine + ports: + - "6379:6379" + volumes: + - ./redis-data:/data + rpc: + image: ghcr.io/fuzzland/cached-eth-rpc:latest + ports: + - "8124:8124" + environment: + - ENDPOINTS=eth-chain=https://rpc.ankr.com/eth,bsc-chain=https://rpc.ankr.com/bsc + - REDIS_URL=redis://docker-redis:6379 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index fb5148d..69854d6 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -7,9 +7,10 @@ for part in "${PARTS[@]}"; do ARGUMENTS+="--endpoint $part " done -# if DATA_PERSISTENCE = 1 is set, then use it -if [ "$DATA_PERSISTENCE" = "1" ]; then - ARGUMENTS+="--datadir /data" +if [ -n "$REDIS_URL" ]; then + ARGUMENTS+="--redis-url $REDIS_URL" + # wait for redis to be ready + sleep 1 fi exec $1 --port 8124 --bind 0.0.0.0 $ARGUMENTS