Skip to content

Instantly share code, notes, and snippets.

@tedder
Last active July 26, 2021 15:01
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tedder/e40460e92adbff07f6890806e12eb444 to your computer and use it in GitHub Desktop.
Save tedder/e40460e92adbff07f6890806e12eb444 to your computer and use it in GitHub Desktop.
helium validator + watchtower (with consensus check) + exporter
# launch: docker-compose up -d
version: "3.7"
services:
validator:
image: quay.io/team-helium/validator:latest-validator-amd64
container_name: validator
init: true
restart: always
ports:
- "2154:2154"
- "127.0.0.1:4467:4467" # jsonrpc
volumes:
- "${HOME}/validator_data/:/var/data"
labels:
"com.centurylinklabs.watchtower.lifecycle.pre-update": >
sh -c 'while [ "$$(miner info in_consensus)" == "true" ]; do echo "in consensus, loop-waiting"; sleep 30; done'
"com.centurylinklabs.watchtower.lifecycle.pre-update-timeout": 43200 # 12hrs should be longer than a validator is in the consensus group.
val_watchtower:
image: containrrr/watchtower:latest
container_name: val_watchtower
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: validator miner_exporter # the container name(s) to monitor
environment:
- WATCHTOWER_POLL_INTERVAL=21600 # check for new image every 6 hrs
- WATCHTOWER_LIFECYCLE_HOOKS=true
#- WATCHTOWER_DEBUG=true # uncomment to see watchtower waiting for consensus
miner_exporter:
image: ghcr.io/tedder/miner_exporter:latest
container_name: miner_exporter
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "127.0.0.1:9825:9825"
@alnjxn
Copy link

alnjxn commented Jun 18, 2021

🙏

@kEND
Copy link

kEND commented Jun 21, 2021

Here's a docker run version for watchtower with the in_consensus pre-update check. (waiting to test in the wild...)

NOTE: This needs tweaking. Watchtower restarts and restarts....

docker run -d \
--restart always \
--name watchtower \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower validator miner_exporter \
--cleanup \
--label=com.centurylinklabs.watchtower.lifecycle.pre-update="sh -c 'while [ "\$\(miner info in_consensus\)" == "true" ]; do echo "in consensus, loop-waiting"; sleep 30; done'" \
--label=com.centurylinklabs.watchtower.lifecycle.pre-update-timeout=43200 \
-e WATCHTOWER_LIFECYCLE_HOOKS=true \
--interval 21600

@andrewboudreau
Copy link

andrewboudreau commented Jun 22, 2021

using the json rpc does work in 0.73, not sure it's the best solution or how to integrate it, but thought I'd share. Also I don't like the dep. on jq

curl -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"info_in_consensus", "params":[]}' http://127.0.0.1:4467 | jq ".result.in_consensus"

@jkowalcz
Copy link

I think you are going to need a "restart: always" in each service section so that everything will start on reboot?

@philltran
Copy link

Thanks for writing this docker-compose.yml file. I believe the volume mount for 'validator' container should be

    volumes:
    - "${HOME}/validator_data:/var/data"

@tedder
Copy link
Author

tedder commented Jun 24, 2021

@philltran removing a trailing slash? It should work either way.

@philltran
Copy link

You are right. The issue I was having was with the quay tag. I needed to use validator for the main net and not val for testnet.

@tedder
Copy link
Author

tedder commented Jun 24, 2021

good call! I was having trouble mentally diffing it.

@jkowalcz
Copy link

@tedder Don't you need a "restart: always" in each service section so that everything will start on reboot?

@tedder
Copy link
Author

tedder commented Jun 25, 2021

@jkowalcz not a bad idea. added.

@Funkyanimal
Copy link

Might want to add 8080 port for light hotspots

@rootulp
Copy link

rootulp commented Jul 26, 2021

https://gist.github.com/rootulp/4fe3a7e420237a5632f3201faa246ab4 has two editions to this docker-compose.yml

  1. Expose 8080 per deployment guide
  2. Increase ulimits to avoid No file descriptors available error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment