Skip to content

Commit

Permalink
Merge branch 'main' into feat/warp_update
Browse files Browse the repository at this point in the history
  • Loading branch information
Trantorian1 committed Nov 29, 2024
2 parents 17eb84d + dd13cb4 commit b91914a
Show file tree
Hide file tree
Showing 8 changed files with 623 additions and 372 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ tmp/

*.info
*.profraw

# Running madara with make and docker compose
.secrets
image.tar.gz
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next release

- feat(warp): added warp update to madara
- docs(readme): updated README.md docs and added Docker Compose support
- fix(log): define RUST_LOG=info by default
- fix(tracing): RUST_LOG filtering support
- fix(fgw): fetch class
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN cargo build --release
FROM debian:bookworm
# Install runtime dependencies
RUN apt-get -y update && \
apt-get install -y openssl ca-certificates tini &&\
apt-get install -y openssl ca-certificates tini curl &&\
apt-get autoremove -y; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*
Expand Down
156 changes: 156 additions & 0 deletions Makefile
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
Loading

0 comments on commit b91914a

Please sign in to comment.