-
Notifications
You must be signed in to change notification settings - Fork 32
/
Makefile
156 lines (112 loc) · 3.91 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# ============================================================================ #
# STARKNET NODE RUNNER #
# ============================================================================ #
define HELP
Madara Node Runner
Helper for running the starknet Madara node.
Usage:
make <target>
Targets:
[ RUNNING MADARA ]
Runs Madara, automatically pulling the required image if it is not already
available. Note that it is also required for you to have added the necessary
secrets to `./secrets/`, or the nodes will fail to start.
- start Starts the Madara node
[ STOPPING MADARA ]
Note that this will only pause container execution and not delete it, its
volume or image.
- stop Stops the Madara node
[ RESTARTING MADARA ]
Restarts Madara, possibly cleaning containers, images and volumes in the
process. Note that it is also required for you to have added the necessary
secrets to `./secrets/`, or the nodes will fail to restart.
- restart Restarts the Madara node
- frestart Perform a full clean and restarts the Madara node
[ LOGGING MADARA ]
This will show logging outputs for the Madara container. Defaults to following
the output, <Ctrl-C> to quit.
- logs View logs for Madara
[ DOWLOAD DEPENDENCIES ]
Images are downloaded from the github container registry. Note that to avoid
continuousy downloading images those are exported to a `tar.gz` as artefacts.
- images Downloads the Madara Docker image
[ CLEANING DEPENDECIES ]
Will remove running containers, images and even local db. Use the latter with
care as removing the local db will force a resync from genesys.
- clean Stop containers and prune images
- clean-db Perform clean and remove local database
- fclean Perform clean-db and remove local images
[ OTHER COMMANDS ]
- help Show this help message
endef
export HELP
SECRETS := .secrets/rpc_api.secret
DB_PATH := /var/lib/madara
DOCKER_COMPOSE := docker compose -f compose.yaml
DOCKER_TAG := madara:latest
DOCKER_IMAGE := ghcr.io/madara-alliance/$(DOCKER_TAG)
DOCKER_GZ := image.tar.gz
# dim white italic
DIM := \033[2;3;37m
# bold cyan
INFO := \033[1;36m
# bold green
PASS := \033[1;32m
# bold red
WARN := \033[1;31m
RESET := \033[0m
.PHONY: all
all: help
.PHONY: help
help:
@echo "$$HELP"
.PHONY: start
start: images $(SECRETS)
@echo -e "$(DIM)running$(RESET) $(PASS)madara$(RESET)"
@$(DOCKER_COMPOSE) up -d
.PHONY: stop
stop:
@echo -e "$(DIM)stopping$(RESET) $(WARN)madara$(RESET)"
@$(DOCKER_COMPOSE) stop
.PHONY: logs
logs:
@echo -e "$(DIM)logs for$(RESET) $(INFO)madara$(RESET)";
@$(DOCKER_COMPOSE) logs -f -n 100 madara;
.PHONY: images
images: $(DOCKER_GZ)
$(DOCKER_GZ):
@echo -e "$(DIM)downloading$(RESET) $(PASS)madara$(RESET)"
@docker pull $(DOCKER_IMAGE)
@docker tag $(DOCKER_IMAGE) $(DOCKER_TAG)
@docker rmi $(DOCKER_IMAGE)
@docker image save -o $(DOCKER_GZ) $(DOCKER_TAG)
.PHONY: clean
clean: stop
@echo -e "$(DIM)pruning containers$(RESET)"
@docker container prune -f
@echo -e "$(DIM)pruning images$(RESET)"
@docker image prune -f
@echo -e "$(WARN)images cleaned$(RESET)"
.PHONY: clean-db
clean-db:
@echo -e "$(WARN)This action will result in irrecoverable loss of data!$(RESET)"
@echo -e "$(DIM)Are you sure you want to proceed?$(RESET) $(PASS)[y/N] $(RESET)" && \
read ans && \
case "$$ans" in \
[yY]*) true;; \
*) false;; \
esac
@make --silent clean
@echo -e "$(DIM)removing madara database on host$(RESET)"
@rm -rf $(DB_PATH);
.PHONY: fclean
fclean: clean-db
@echo -e "$(DIM)removing local images tar.gz$(RESET)"
@rm -rf $(DOCKER_GZ)
@echo -e "$(WARN)artefacts cleaned$(RESET)"
.PHONY: restart
restart: clean
@make --silent start
.PHONY: frestart
frestart: fclean
@make --silent start