Skip to content

Commit c66bdd2

Browse files
committed
Makefile: add target to run an archive node
1 parent 9507c50 commit c66bdd2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
NIGHTLY_RUST_VERSION = "nightly"
44

5+
# PostgreSQL configuration for archive node
6+
OPEN_ARCHIVE_ADDRESS ?= http://localhost:3007
7+
PG_USER ?= openmina
8+
PG_PW ?= openminaopenmina
9+
PG_DB ?= openmina_archive
10+
PG_HOST ?= localhost
11+
PG_PORT ?= 5432
12+
13+
# Utilities
14+
NETWORK ?= devnet
15+
516
.PHONY: help
617
help: ## Ask for help!
718
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@@ -218,3 +229,30 @@ docker-build-producer-dashboard: ## Build producer dashboard Docker image
218229
docker-build-test: ## Build test Docker image
219230
docker build -t $(DOCKER_ORG)/openmina-test:$(GIT_COMMIT) \
220231
-f node/testing/docker/Dockerfile.test node/testing/docker/
232+
233+
# Postgres related targets + archive node
234+
.PHONY: run-archive
235+
run-archive: build-release ## Run an archive node with local storage
236+
OPENMINA_ARCHIVE_ADDRESS=$(OPENMINA_ARCHIVE_ADDRESS) \
237+
cargo run --bin openmina \
238+
--release -- \
239+
node \
240+
--archive-archiver-process \
241+
--archive-local-storage
242+
--network $(NETWORK)
243+
244+
.PHONY: postgres-clean
245+
postgres-clean:
246+
@echo "Dropping DB: ${PG_DB} and user: ${PG_USER}"
247+
@sudo -u postgres psql -c "DROP DATABASE IF EXISTS ${PG_DB}"
248+
@sudo -u postgres psql -c "DROP DATABASE IF EXISTS ${PG_USER}"
249+
@sudo -u postgres psql -c "DROP ROLE IF EXISTS ${PG_USER}"
250+
@echo "Cleanup complete."
251+
252+
.PHONY: postgres-setup
253+
postgres-setup: ## Set up PostgreSQL database for archive node
254+
@echo "Setting up PostgreSQL database: ${PG_DB} with user: ${PG_USER}"
255+
@sudo -u postgres createuser -d -r -s $(PG_USER) 2>/dev/null || true
256+
@sudo -u postgres psql -c "ALTER USER $(PG_USER) PASSWORD '$(PG_PW)'" 2>/dev/null || true
257+
@sudo -u postgres createdb -O $(PG_USER) $(PG_DB) 2>/dev/null || true
258+
@sudo -u postgres createdb -O $(PG_USER) $(PG_USER) 2>/dev/null || true

0 commit comments

Comments
 (0)