-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (102 loc) · 4.54 KB
/
Copy pathMakefile
File metadata and controls
126 lines (102 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
TAG=latest
# COLOR CONFIG
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
TARGET_MAX_CHAR_NUM=20
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' CONFIG_PATH=<config_path> ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## check that config file is loaded correctly
check-env:
@if [ -z "$(CONFIG_PATH)" ]; then echo "env_file env var is not set. aborting." && exit 1; fi
## Build validator service
build:
@echo "building validator services and cranker"
git submodule update --init --recursive
cargo build --release
## Run cargo tidy scripts
tidy:
cargo sort --workspace
cargo +nightly udeps
cargo clippy --fix --allow-staged --allow-dirty
## Start local database
start-database-local:
@echo "starting mongodb (docker)"
docker run --name mongodb -d -p 27017:27017 mongo
## Stop local database
stop-database-local:
@echo "stopping mongodb as background process"
docker stop mongodb
## Run an instance of the indexer
run-indexer:
@echo "starting indexer"
@echo $(MONGO_CONNECTION_URI)
@echo $(MONGO_DB_NAME)
@echo $(VALIDATORS_APP_TOKEN)
VALIDATORS_APP_TOKEN=$(VALIDATORS_APP_TOKEN) ./target/release/kobe-writer-service --mongo-connection-uri "$(MONGO_CONNECTION_URI)" --mongo-db-name $(MONGO_DB_NAME)
## Run an instance of the cranker
run-cranker-dry:
@echo "starting a dry run of the Cranker (Unimplemented)"
## Start graphql service
start-graphql: ## start graphql service
@echo "starting graphql service on cluster $(SOLANA_CLUSTER)"
RUST_LOG=info cargo run --manifest-path api/Cargo.toml -- \
--ip $(GRAPHQL_IP) --port $(GRAPHQL_PORT) --mongo-connection-uri $(MONGO_CONNECTION_URI) --mongo-db-name $(MONGO_DB_NAME) --solana-cluster $(SOLANA_CLUSTER)
## Run all docker containers in the foreground
run-docker: check-env
@echo "starting docker containers"
@echo $(CONFIG_PATH)
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose --env-file $(CONFIG_PATH) up --build --remove-orphans
## Check docker env variables, given a loaded config file
check-docker: check-env
@echo "checking docker env variables..."
docker compose --env-file $(CONFIG_PATH) config
## Build and start rest api in background, restarting if exists
start-api: check-env
@echo "restarting api"
@echo $(CONFIG_PATH)
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose --env-file $(CONFIG_PATH) up -d --build --remove-orphans api-mainnet
## Build and start rest api in background, restarting if exists
start-api-testnet: check-env
@echo "restarting api"
@echo $(CONFIG_PATH)
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose --env-file $(CONFIG_PATH) up -d --build --remove-orphans api-testnet
## Build and start db writer in background, restarting if exists
start-db-writer: check-env
@echo "restarting db writer"
@echo $(CONFIG_PATH)
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose --env-file $(CONFIG_PATH) up -d --build --remove-orphans writer-service-mainnet
make start-testnet-db-writer: check-env
@echo "restarting testnet writer"
@echo $(CONFIG_PATH)
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -p testnet --env-file $(CONFIG_PATH) up -d --build --remove-orphans writer-service-testnet
## Build and start cranker in background, restarting if exists
start-cranker: check-env
@echo "restarting cranker"
@echo $(CONFIG_PATH)
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose --env-file $(CONFIG_PATH) up -d --build --remove-orphans cranker
## Build and start steward writer service mainnet in background, restarting if exists
start-steward-writer-mainnet: check-env
@echo "restarting steward writer mainnet"
@echo $(CONFIG_PATH)
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose --env-file $(CONFIG_PATH) up -d --build --remove-orphans steward-writer-service-mainnet
## Build and start steward writer service testnet in background, restarting if exists
start-steward-writer-testnet: check-env
@echo "restarting steward writer testnet"
@echo $(CONFIG_PATH)
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -p testnet --env-file $(CONFIG_PATH) up -d --build --remove-orphans steward-writer-service-testnet