-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into storage-proofs
- Loading branch information
Showing
9 changed files
with
616 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,7 @@ tmp/ | |
|
||
*.info | ||
*.profraw | ||
|
||
# Running madara with make and docker compose | ||
.secrets | ||
image.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
Oops, something went wrong.