2019-03-19 17:35:34 +00:00
|
|
|
GIT_ROOT = $(shell git rev-parse --show-toplevel)
|
|
|
|
|
2019-12-20 13:09:39 +00:00
|
|
|
RED := $(shell tput -Txterm setaf 1)
|
|
|
|
GRN := $(shell tput -Txterm setaf 2)
|
|
|
|
YLW := $(shell tput -Txterm setaf 3)
|
|
|
|
RST := $(shell tput -Txterm sgr0)
|
|
|
|
BLD := $(shell tput bold)
|
2019-03-19 17:35:34 +00:00
|
|
|
|
|
|
|
UID = $(shell id -u)
|
|
|
|
GID = $(shell id -g)
|
|
|
|
|
|
|
|
# Settings
|
|
|
|
export LOG_LEVEL ?= 3
|
2020-02-03 19:02:23 +00:00
|
|
|
export LISTEN_PORT ?= 30301
|
2019-03-19 17:35:34 +00:00
|
|
|
export API_MODULES ?= eth,net,web3,admin
|
|
|
|
export CONTAINER_NAME ?= status-go-bootnode
|
|
|
|
export CONTAINER_IMAGE ?= statusteam/bootnode:latest
|
|
|
|
# Necessary to make bootnode available publicly
|
|
|
|
export PUBLIC_IP ?= $(shell curl -s https://ipecho.net/plain)
|
|
|
|
|
|
|
|
all: checks start show info enode
|
|
|
|
|
|
|
|
checks:
|
2019-12-16 22:27:01 +00:00
|
|
|
ifeq (, $(shell which docker))
|
2019-12-20 13:09:39 +00:00
|
|
|
$(error $(RED)No 'docker' in your $$PATH. Please install it$(RST))
|
2019-12-16 22:27:01 +00:00
|
|
|
endif
|
|
|
|
ifeq (, $(shell docker version | grep Server))
|
2019-12-20 13:09:39 +00:00
|
|
|
$(error $(RED)No permissions to run 'docker'. Add yourself to docker group$(RST))
|
2019-12-16 22:27:01 +00:00
|
|
|
endif
|
2019-03-19 17:35:34 +00:00
|
|
|
ifeq (, $(shell which docker-compose))
|
2019-12-20 13:09:39 +00:00
|
|
|
$(error $(RED)No 'docker-compose' in your $$PATH. Please install it$(RST))
|
2019-03-19 17:35:34 +00:00
|
|
|
endif
|
|
|
|
ifeq (, $(shell which jq))
|
2019-12-20 13:09:39 +00:00
|
|
|
$(error $(RED)No 'jq' in your $$PATH. Please install it$(RST))
|
2019-03-19 17:35:34 +00:00
|
|
|
endif
|
|
|
|
ifndef PUBLIC_IP
|
2019-12-20 13:09:39 +00:00
|
|
|
$(error $(RED)$$PUBLIC_IP not set! Export it as environment variable$(RST))
|
2019-03-19 17:35:34 +00:00
|
|
|
endif
|
|
|
|
ifndef CONTAINER_NAME
|
2019-12-20 13:09:39 +00:00
|
|
|
$(error $(RED)$$CONTAINER_NAME not set! Export it as environment variable$(RST))
|
2019-03-19 17:35:34 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
start: keys/nodekey keys/nodeaddr
|
|
|
|
docker-compose up -d
|
|
|
|
|
|
|
|
stop:
|
|
|
|
docker-compose down
|
|
|
|
|
|
|
|
logs:
|
|
|
|
docker-compose logs -f -t --tail=100
|
|
|
|
|
|
|
|
enode: keys/nodeaddr
|
|
|
|
@echo "enode://$(shell cat keys/nodeaddr)@$(PUBLIC_IP):$(LISTEN_PORT)"
|
|
|
|
|
|
|
|
info:
|
2019-12-20 13:09:39 +00:00
|
|
|
@echo "$(GRN)Your bootnode is listening on:$(RST) $(BLD)$(PUBLIC_IP):$(LISTEN_PORT)$(RST)"
|
|
|
|
@echo "$(YLW)Make sure that address and UDP port are available from the internet!$(RST)"
|
|
|
|
@echo "$(GRN)Your enode address is:$(RST)"
|
2019-03-19 17:35:34 +00:00
|
|
|
|
|
|
|
keys:
|
|
|
|
@mkdir -p keys
|
|
|
|
|
|
|
|
keys/nodekey: keys ##@ Generate a node key
|
|
|
|
@docker run --rm \
|
|
|
|
-u $(UID):$(GID) \
|
|
|
|
--entrypoint=bootnode \
|
|
|
|
-v $(PWD)/keys:/keys:rw \
|
2019-11-28 23:56:34 +00:00
|
|
|
$(CONTAINER_IMAGE) \
|
2019-03-19 17:35:34 +00:00
|
|
|
-genkey=/keys/nodekey
|
2019-12-20 13:09:39 +00:00
|
|
|
@echo "$(GRN)Created key for Bootnode: keys/nodekey$(RST)"
|
2019-03-19 17:35:34 +00:00
|
|
|
|
|
|
|
keys/nodeaddr: keys ##@ Save node address for given key
|
|
|
|
@docker run --rm \
|
|
|
|
-u $(UID):$(GID) \
|
|
|
|
--entrypoint=sh \
|
|
|
|
-v $(PWD)/keys:/keys:rw \
|
2019-11-28 23:56:34 +00:00
|
|
|
$(CONTAINER_IMAGE) \
|
2019-03-19 17:35:34 +00:00
|
|
|
-c 'bootnode -writeaddress -nodekey=/keys/nodekey > /keys/nodeaddr'
|
|
|
|
|
|
|
|
show:
|
|
|
|
@docker ps --filter='name=$(CONTAINER_NAME)' --format="table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Ports}}"
|
|
|
|
|
|
|
|
clean:
|
|
|
|
docker-compose rm -s -f
|