Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# OpenMina Makefile

# Rust
NIGHTLY_RUST_VERSION = "nightly"

# Docker
DOCKER_ORG ?= openmina

# PostgreSQL configuration for archive node
OPEN_ARCHIVE_ADDRESS ?= http://localhost:3007
PG_USER ?= openmina
PG_PW ?= openminaopenmina
PG_DB ?= openmina_archive
PG_HOST ?= localhost
PG_PORT ?= 5432

# Utilities
NETWORK ?= devnet
GIT_COMMIT := $(shell git rev-parse --short=8 HEAD)

.PHONY: help
help: ## Ask for help!
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down Expand Up @@ -157,8 +173,6 @@ test-vrf: ## Run VRF tests, requires nightly Rust
@cd vrf && cargo +nightly test --release -- -Z unstable-options --report-time

# Docker build targets
DOCKER_ORG ?= openmina
GIT_COMMIT := $(shell git rev-parse --short=8 HEAD)

.PHONY: docker-build-all
docker-build-all: docker-build-bootstrap-sandbox docker-build-debugger \
Expand Down Expand Up @@ -218,3 +232,30 @@ docker-build-producer-dashboard: ## Build producer dashboard Docker image
docker-build-test: ## Build test Docker image
docker build -t $(DOCKER_ORG)/openmina-test:$(GIT_COMMIT) \
-f node/testing/docker/Dockerfile.test node/testing/docker/

# Postgres related targets + archive node
.PHONY: run-archive
run-archive: build-release ## Run an archive node with local storage
OPENMINA_ARCHIVE_ADDRESS=$(OPENMINA_ARCHIVE_ADDRESS) \
cargo run --bin openmina \
--release -- \
node \
--archive-archiver-process \
--archive-local-storage
--network $(NETWORK)

.PHONY: postgres-clean
postgres-clean:
@echo "Dropping DB: ${PG_DB} and user: ${PG_USER}"
@sudo -u postgres psql -c "DROP DATABASE IF EXISTS ${PG_DB}"
@sudo -u postgres psql -c "DROP DATABASE IF EXISTS ${PG_USER}"
@sudo -u postgres psql -c "DROP ROLE IF EXISTS ${PG_USER}"
@echo "Cleanup complete."

.PHONY: postgres-setup
postgres-setup: ## Set up PostgreSQL database for archive node
@echo "Setting up PostgreSQL database: ${PG_DB} with user: ${PG_USER}"
@sudo -u postgres createuser -d -r -s $(PG_USER) 2>/dev/null || true
@sudo -u postgres psql -c "ALTER USER $(PG_USER) PASSWORD '$(PG_PW)'" 2>/dev/null || true
@sudo -u postgres createdb -O $(PG_USER) $(PG_DB) 2>/dev/null || true
@sudo -u postgres createdb -O $(PG_USER) $(PG_USER) 2>/dev/null || true
Loading