From 78508289894dc41a876dff4fd2794214982b93af Mon Sep 17 00:00:00 2001 From: teddy931130 Date: Thu, 16 Jan 2025 00:17:18 +0200 Subject: [PATCH] add a healthcheck and resource limits --- docker-compose.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 026b1cb6cb..360cf79233 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,10 +8,13 @@ services: # build: # dockerfile: Dockerfile # context: . + ### override default 'geth' entrypoint to use a local devnet + ### with persistent blockchain and account data (--datadir flag) entrypoint: "geth --dev --datadir /root/.ethereum --http --http.api eth,web3,net --http.addr 0.0.0.0 --http.corsdomain 'https://remix.ethereum.org'" volumes: - "./geth-data:/root/.ethereum" + ### keep to pass any env vars if necessary # env_file: # - ".env" @@ -23,7 +26,21 @@ services: networks: go-ethereum: ipv4_address: 172.25.0.2 - restart: "no" + healthcheck: + ### test whether a tcp connection on the RPC port is successful + test: ["CMD-SHELL", "nc -w 1 -v localhost 8545 || exit 1"] + interval: 30s + timeout: 5s + retries: 3 + deploy: + resources: + reservations: + cpus: "1" + memory: "1G" + limits: + cpus: "2" + memory: "2G" + restart: "on-failure:3" networks: go-ethereum: