Skip to content

Commit

Permalink
update docker
Browse files Browse the repository at this point in the history
  • Loading branch information
publicqi committed Jan 4, 2024
1 parent 4bf1233 commit a9a7419
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/target

/run.sh
data
data
redis-data
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a9a7419

Please sign in to comment.