|
1 | 1 | # OpenMina Makefile
|
2 | 2 |
|
| 3 | +# Rust |
3 | 4 | NIGHTLY_RUST_VERSION = "nightly"
|
4 | 5 |
|
| 6 | +# Docker |
| 7 | +DOCKER_ORG ?= openmina |
| 8 | + |
| 9 | +# PostgreSQL configuration for archive node |
| 10 | +OPEN_ARCHIVE_ADDRESS ?= http://localhost:3007 |
| 11 | +PG_USER ?= openmina |
| 12 | +PG_PW ?= openminaopenmina |
| 13 | +PG_DB ?= openmina_archive |
| 14 | +PG_HOST ?= localhost |
| 15 | +PG_PORT ?= 5432 |
| 16 | + |
| 17 | +# Utilities |
| 18 | +NETWORK ?= devnet |
| 19 | +GIT_COMMIT := $(shell git rev-parse --short=8 HEAD) |
| 20 | + |
5 | 21 | .PHONY: help
|
6 | 22 | help: ## Ask for help!
|
7 | 23 | @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
@@ -157,8 +173,6 @@ test-vrf: ## Run VRF tests, requires nightly Rust
|
157 | 173 | @cd vrf && cargo +nightly test --release -- -Z unstable-options --report-time
|
158 | 174 |
|
159 | 175 | # Docker build targets
|
160 |
| -DOCKER_ORG ?= openmina |
161 |
| -GIT_COMMIT := $(shell git rev-parse --short=8 HEAD) |
162 | 176 |
|
163 | 177 | .PHONY: docker-build-all
|
164 | 178 | docker-build-all: docker-build-bootstrap-sandbox docker-build-debugger \
|
@@ -218,3 +232,30 @@ docker-build-producer-dashboard: ## Build producer dashboard Docker image
|
218 | 232 | docker-build-test: ## Build test Docker image
|
219 | 233 | docker build -t $(DOCKER_ORG)/openmina-test:$(GIT_COMMIT) \
|
220 | 234 | -f node/testing/docker/Dockerfile.test node/testing/docker/
|
| 235 | + |
| 236 | +# Postgres related targets + archive node |
| 237 | +.PHONY: run-archive |
| 238 | +run-archive: build-release ## Run an archive node with local storage |
| 239 | + OPENMINA_ARCHIVE_ADDRESS=$(OPENMINA_ARCHIVE_ADDRESS) \ |
| 240 | + cargo run --bin openmina \ |
| 241 | + --release -- \ |
| 242 | + node \ |
| 243 | + --archive-archiver-process \ |
| 244 | + --archive-local-storage |
| 245 | + --network $(NETWORK) |
| 246 | + |
| 247 | +.PHONY: postgres-clean |
| 248 | +postgres-clean: |
| 249 | + @echo "Dropping DB: ${PG_DB} and user: ${PG_USER}" |
| 250 | + @sudo -u postgres psql -c "DROP DATABASE IF EXISTS ${PG_DB}" |
| 251 | + @sudo -u postgres psql -c "DROP DATABASE IF EXISTS ${PG_USER}" |
| 252 | + @sudo -u postgres psql -c "DROP ROLE IF EXISTS ${PG_USER}" |
| 253 | + @echo "Cleanup complete." |
| 254 | + |
| 255 | +.PHONY: postgres-setup |
| 256 | +postgres-setup: ## Set up PostgreSQL database for archive node |
| 257 | + @echo "Setting up PostgreSQL database: ${PG_DB} with user: ${PG_USER}" |
| 258 | + @sudo -u postgres createuser -d -r -s $(PG_USER) 2>/dev/null || true |
| 259 | + @sudo -u postgres psql -c "ALTER USER $(PG_USER) PASSWORD '$(PG_PW)'" 2>/dev/null || true |
| 260 | + @sudo -u postgres createdb -O $(PG_USER) $(PG_DB) 2>/dev/null || true |
| 261 | + @sudo -u postgres createdb -O $(PG_USER) $(PG_USER) 2>/dev/null || true |
0 commit comments