|
2 | 2 |
|
3 | 3 | NIGHTLY_RUST_VERSION = "nightly"
|
4 | 4 |
|
| 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 | + |
5 | 16 | .PHONY: help
|
6 | 17 | help: ## Ask for help!
|
7 | 18 | @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
|
218 | 229 | docker-build-test: ## Build test Docker image
|
219 | 230 | docker build -t $(DOCKER_ORG)/openmina-test:$(GIT_COMMIT) \
|
220 | 231 | -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