-
Notifications
You must be signed in to change notification settings - Fork 245
/
Makefile
104 lines (84 loc) · 2.83 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
export GIT_ROOT = $(shell git rev-parse --show-toplevel)
# Useful for showing enode address
PUBLIC_IP ?= $(shell curl -s https://ipecho.net/plain)
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)
UID = $(shell id -u)
GID = $(shell id -g)
# Settings
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
export API_MODULES ?= eth,web3,admin
NODE_ADDR = $(shell cat keys/nodeaddr)
ENODE_ADDR = enode://$(NODE_ADDR)@$(PUBLIC_IP):$(LISTEN_PORT)
define INFO_MSG
* $(GRN)Your bootnode is listening on:$(RST) $(BLD)$(PUBLIC_IP):$(LISTEN_PORT)$(RST)
* $(GRN)Your enode address is:$(RST)
$(ENODE_ADDR)
$(YLW)Make sure that address and UDP port are available from the internet!$(RST)
endef
export INFO_MSG
all: checks start show info enode-qr
checks:
ifeq (, $(shell which docker))
$(error $(RED)No 'docker' in your $$PATH. Please install it$(RST))
endif
ifeq (, $(shell docker version | grep Server))
$(error $(RED)No permissions to run 'docker'. Add yourself to docker group$(RST))
endif
ifeq (, $(shell which docker-compose))
$(error $(RED)No 'docker-compose' in your $$PATH. Please install it$(RST))
endif
ifeq (, $(shell which jq))
$(error $(RED)No 'jq' in your $$PATH. Please install it$(RST))
endif
ifndef PUBLIC_IP
$(error $(RED)$$PUBLIC_IP not set! Export it as environment variable$(RST))
endif
ifndef CONTAINER_NAME
$(error $(RED)$$CONTAINER_NAME not set! Export it as environment variable$(RST))
endif
enode: keys/nodeaddr
@echo $(ENODE_ADDR)
enode-qr: keys/nodeaddr
@qrencode -t UTF8 $(ENODE_ADDR)
logs: LOG_LINES ?= 100
logs:
docker-compose logs -f -t --tail=$(LOG_LINES)
info:
@echo "$$INFO_MSG"
keys:
@mkdir -p keys
start: keys/nodekey keys/nodeaddr
@echo " * $(GRN)Starting '$(CONTAINER_NAME)' container...$(RST)"
docker-compose $(COMPOSE_UP_FLAGS) up -d
stop:
@echo " * $(YLW)Stopping '$(CONTAINER_NAME)' container...$(RST)"
docker-compose down
keys/nodekey: keys ##@ Generate a node key
@echo " * $(GRN)Generating '$(CONTAINER_NAME)' keys...$(RST)"
@docker run --rm \
-u $(UID):$(GID) \
--entrypoint=bootnode \
-v $(PWD)/keys:/keys:rw \
$(CONTAINER_IMG) \
-genkey=/keys/nodekey
@echo " * $(GRN)Created key for Bootnode: keys/nodekey$(RST)"
keys/nodeaddr: keys ##@ Save node address for given key
@echo " * $(GRN)Saving '$(CONTAINER_NAME)' enode address...$(RST)"
@docker run --rm \
-u $(UID):$(GID) \
--entrypoint=sh \
-v $(PWD)/keys:/keys:rw \
$(CONTAINER_IMG) \
-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