2021-08-17 17:15:40 +00:00
|
|
|
export GIT_ROOT = $(shell git rev-parse --show-toplevel)
|
|
|
|
# Useful for showing enode address
|
|
|
|
PUBLIC_IP ?= $(shell curl -s https://ipecho.net/plain)
|
2019-03-19 17:35:34 +00:00
|
|
|
|
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
|
2021-01-20 13:08:14 +00:00
|
|
|
export CONTAINER_TAG ?= v0.64.3
|
|
|
|
export CONTAINER_IMG ?= statusteam/bootnode
|
|
|
|
export CONTAINER_NAME ?= status-go-bootnode
|
|
|
|
export LOG_LEVEL ?= 3
|
|
|
|
export LISTEN_PORT ?= 30301
|
2021-08-17 17:15:40 +00:00
|
|
|
export API_MODULES ?= eth,web3,admin
|
|
|
|
|
2021-08-24 13:13:10 +00:00
|
|
|
NODE_ADDR = $(shell cat keys/nodeaddr)
|
|
|
|
ENODE_ADDR = enode://$(NODE_ADDR)@$(PUBLIC_IP):$(LISTEN_PORT)
|
|
|
|
|
2021-08-17 17:15:40 +00:00
|
|
|
define INFO_MSG
|
|
|
|
* $(GRN)Your bootnode is listening on:$(RST) $(BLD)$(PUBLIC_IP):$(LISTEN_PORT)$(RST)
|
2021-08-24 13:13:10 +00:00
|
|
|
* $(GRN)Your enode address is:$(RST)
|
|
|
|
$(ENODE_ADDR)
|
2021-08-17 17:15:40 +00:00
|
|
|
|
|
|
|
$(YLW)Make sure that address and UDP port are available from the internet!$(RST)
|
|
|
|
|
|
|
|
endef
|
|
|
|
export INFO_MSG
|
2019-03-19 17:35:34 +00:00
|
|
|
|
2021-08-24 13:13:10 +00:00
|
|
|
all: checks start show info enode-qr
|
2019-03-19 17:35:34 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-08-17 17:15:40 +00:00
|
|
|
enode: keys/nodeaddr
|
2021-08-24 13:13:10 +00:00
|
|
|
@echo $(ENODE_ADDR)
|
|
|
|
|
|
|
|
enode-qr: keys/nodeaddr
|
|
|
|
@qrencode -t UTF8 $(ENODE_ADDR)
|
2019-03-19 17:35:34 +00:00
|
|
|
|
2021-08-24 13:13:10 +00:00
|
|
|
logs: LOG_LINES ?= 100
|
2019-03-19 17:35:34 +00:00
|
|
|
logs:
|
2021-08-24 13:13:10 +00:00
|
|
|
docker-compose logs -f -t --tail=$(LOG_LINES)
|
2019-03-19 17:35:34 +00:00
|
|
|
|
|
|
|
info:
|
2021-08-17 17:15:40 +00:00
|
|
|
@echo "$$INFO_MSG"
|
2019-03-19 17:35:34 +00:00
|
|
|
|
|
|
|
keys:
|
|
|
|
@mkdir -p keys
|
|
|
|
|
2021-08-17 17:15:40 +00:00
|
|
|
start: keys/nodekey keys/nodeaddr
|
|
|
|
@echo " * $(GRN)Starting '$(CONTAINER_NAME)' container...$(RST)"
|
|
|
|
docker-compose up -d
|
|
|
|
|
|
|
|
stop:
|
|
|
|
@echo " * $(YLW)Stopping '$(CONTAINER_NAME)' container...$(RST)"
|
|
|
|
docker-compose down
|
|
|
|
|
2019-03-19 17:35:34 +00:00
|
|
|
keys/nodekey: keys ##@ Generate a node key
|
2021-08-17 17:15:40 +00:00
|
|
|
@echo " * $(GRN)Generating '$(CONTAINER_NAME)' keys...$(RST)"
|
2019-03-19 17:35:34 +00:00
|
|
|
@docker run --rm \
|
|
|
|
-u $(UID):$(GID) \
|
|
|
|
--entrypoint=bootnode \
|
|
|
|
-v $(PWD)/keys:/keys:rw \
|
2021-01-20 13:08:14 +00:00
|
|
|
$(CONTAINER_IMG) \
|
2019-03-19 17:35:34 +00:00
|
|
|
-genkey=/keys/nodekey
|
2021-08-17 17:15:40 +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
|
2021-08-17 17:15:40 +00:00
|
|
|
@echo " * $(GRN)Saving '$(CONTAINER_NAME)' enode address...$(RST)"
|
2019-03-19 17:35:34 +00:00
|
|
|
@docker run --rm \
|
|
|
|
-u $(UID):$(GID) \
|
|
|
|
--entrypoint=sh \
|
|
|
|
-v $(PWD)/keys:/keys:rw \
|
2021-01-20 13:08:14 +00:00
|
|
|
$(CONTAINER_IMG) \
|
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
|