This repository was archived by the owner on Apr 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
227 lines (196 loc) · 9 KB
/
Copy pathMakefile
File metadata and controls
227 lines (196 loc) · 9 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# Directory Configuration
REGISTRY ?= localhost
IMAGE_NAME := waypoint
DEFAULT_TAG := latest
ARGS ?=
# Import environment variables from .env file if it exists
ifneq (,$(wildcard ./.env))
include .env
export
endif
.PHONY: proto clean build run backfill-queue backfill-queue-fids backfill-queue-max backfill-worker backfill-update-user-data backfill-update-user-data-max backfill-onchain-all backfill-onchain-fid backfill-onchain-missing migrate test docker-build docker-run docker-push docker-tag metrics-start metrics-stop metrics-open fmt fmt-rust fmt-biome changelog help env-setup
# Create a .env file from .env.example if it doesn't exist
env-setup:
@if [ ! -f .env ]; then \
echo "Creating .env file from .env.example"; \
cp .env.example .env; \
echo "Created .env file. Please edit it with your configuration."; \
else \
echo ".env file already exists. Skipping."; \
fi
proto:
git submodule update --init --recursive
build: proto
SQLX_OFFLINE=true cargo build
clean:
cargo clean
run: proto build env-setup
cargo run -- start $(ARGS)
backfill-queue: proto build env-setup
@echo "Queuing FIDs for backfill (using sum of all FIDs in shards as max)"
cargo run -- backfill fid queue $(ARGS)
backfill-queue-fids: proto build env-setup
@if [ "$(FIDS)" = "" ]; then \
echo "Please specify FIDS=<comma-separated list of FIDs> to backfill"; \
exit 1; \
fi
cargo run -- backfill fid queue --fids $(FIDS) $(ARGS)
backfill-queue-max: proto build env-setup
@if [ "$(MAX_FID)" = "" ]; then \
echo "Please specify MAX_FID=<number> to backfill up to"; \
exit 1; \
fi
cargo run -- backfill fid queue --max-fid $(MAX_FID) $(ARGS)
backfill-worker: proto build env-setup
BACKFILL_CONCURRENCY=50 cargo run -- backfill fid worker $(ARGS)
# Run the user-data update process
backfill-update-user-data: proto build env-setup
cargo run --release -- backfill fid user-data $(ARGS)
# Run the user-data update process with max FID limit
backfill-update-user-data-max: proto build env-setup
@if [ "$(MAX_FID)" = "" ]; then \
echo "Please specify MAX_FID=<number> to update user data up to"; \
exit 1; \
fi
cargo run --release -- backfill fid user-data --max-fid $(MAX_FID) $(ARGS)
# Database migration commands
migrate: env-setup
@echo "Running database migrations..."
@echo "Note: Migrations will be automatically applied when the application starts"
@echo "To run migrations manually, execute the SQL files in migrations/ directory"
@echo "Latest migration: $$(ls migrations/*.sql 2>/dev/null | sort | tail -1)"
# Onchain events backfill commands
backfill-onchain-all: proto build env-setup
@echo "Backfilling onchain events for all FIDs (this may take a while)"
@echo "Use CTRL+C to cancel if needed"
@echo "This will backfill signer, signer_migrated, id_register, storage_rent, and tier_purchase events"
SQLX_OFFLINE=true cargo run --release -- backfill onchain-events --all $(ARGS)
backfill-onchain-fid: proto build env-setup
@if [ "$(FID)" = "" ]; then \
echo "Please specify FID=<fid_number> to backfill onchain events for"; \
exit 1; \
fi
@echo "Backfilling onchain events for FID: $(FID)"
SQLX_OFFLINE=true cargo run --release -- backfill onchain-events --fid $(FID) $(ARGS)
backfill-onchain-missing: proto build env-setup
@if [ "$(EVENT_TYPE)" = "" ]; then \
echo "Please specify EVENT_TYPE=<signer|signer_migrated|id_register|storage_rent|tier_purchase> to backfill missing events"; \
echo "Example: make backfill-onchain-missing EVENT_TYPE=signer"; \
exit 1; \
fi
@echo "Backfilling missing $(EVENT_TYPE) events for all FIDs"
SQLX_OFFLINE=true cargo run --release -- backfill onchain-events --event-type $(EVENT_TYPE) $(ARGS)
# Run the container with proper env vars and port mapping
docker-run: env-setup
docker run -it --rm \
-p ${PORT:-8080}:${PORT:-8080} \
--env-file .env \
-e WAYPOINT_DATABASE__URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@host.docker.internal:5432/${POSTGRES_DB:-waypoint} \
-e WAYPOINT_REDIS__URL=redis://host.docker.internal:6379 \
-e HOST=0.0.0.0 \
$(REGISTRY)/$(IMAGE_NAME):$(DEFAULT_TAG)
# Build Docker image using buildx
docker-build:
docker buildx build --platform linux/amd64,linux/arm64 -t $(REGISTRY)/$(IMAGE_NAME):$(DEFAULT_TAG) .
# Push Docker image to registry
docker-push:
docker buildx build --platform linux/amd64,linux/arm64 -t $(REGISTRY)/$(IMAGE_NAME):$(DEFAULT_TAG) . --push
# Build and tag Docker image with specific tag
docker-tag:
@if [ "$(TAG)" = "" ]; then \
echo "Please specify TAG=<version> to tag the image"; \
exit 1; \
fi
docker buildx build --platform linux/amd64,linux/arm64 -t $(REGISTRY)/$(IMAGE_NAME):$(TAG) . --push
test: proto build env-setup
cargo test
# Format code
fmt: fmt-rust fmt-biome
# Format Rust code
fmt-rust:
cargo fmt --all
# Format JavaScript/TypeScript with Biome
fmt-biome:
@echo "Formatting with Biome..."
@if command -v biome >/dev/null 2>&1; then \
biome format --write .; \
else \
echo "Biome is not installed. Skipping."; \
fi
# Metrics commands
metrics-start:
@echo "Starting metrics infrastructure..."
cd grafana && docker-compose up -d
metrics-stop:
@echo "Stopping metrics infrastructure..."
cd grafana && docker-compose down
metrics-open:
@echo "Opening Grafana dashboard in browser..."
open http://localhost:3000 || xdg-open http://localhost:3000 || echo "Could not open browser automatically. Please visit http://localhost:3000"
# Generate changelog using git-cliff
changelog:
@echo "Generating changelog..."
@if command -v git-cliff >/dev/null 2>&1; then \
git-cliff -o CHANGELOG.md; \
else \
echo "git-cliff is not installed. Please install it with 'cargo install git-cliff'."; \
exit 1; \
fi
# Help target - displays available commands
help:
@echo "Waypoint Makefile Commands:"
@echo ""
@echo "Environment Setup:"
@echo " make env-setup - Create .env file from .env.example if it doesn't exist"
@echo ""
@echo "Development:"
@echo " make build - Build the project"
@echo " make run - Run the main service"
@echo " make test - Run tests"
@echo " make fmt - Format all code"
@echo ""
@echo "Database:"
@echo " make migrate - Show database migration information"
@echo ""
@echo "Backfill:"
@echo " FID-Based Backfill:"
@echo " make backfill-queue - Queue all FIDs for backfill (using sum of FIDs from all shards)"
@echo " make backfill-queue-fids FIDS=1,2,3 - Queue specific FIDs"
@echo " make backfill-queue-max MAX_FID=1000 - Queue FIDs up to 1000"
@echo " make backfill-worker - Run backfill worker (50 concurrent jobs by default)"
@echo " make backfill-update-user-data - Update user_data for all FIDs"
@echo " make backfill-update-user-data-max MAX_FID=1000 - Update user_data for FIDs up to 1000"
@echo ""
@echo " Onchain Events Backfill:"
@echo " make backfill-onchain-all - Backfill onchain events for all FIDs (comprehensive)"
@echo " make backfill-onchain-fid FID=12345 - Backfill onchain events for specific FID"
@echo " make backfill-onchain-missing EVENT_TYPE=signer - Backfill missing events of specific type"
@echo ""
@echo "Docker:"
@echo " make docker-build - Build Docker image"
@echo " make docker-run - Run Docker container using environment from .env"
@echo " make docker-push - Push image to registry ($(REGISTRY)/$(IMAGE_NAME):$(DEFAULT_TAG))"
@echo " make docker-tag TAG=v1.0.0 - Build and push with specific tag"
@echo ""
@echo "Metrics:"
@echo " make metrics-start - Start metrics infrastructure (Grafana, etc.)"
@echo " make metrics-stop - Stop metrics infrastructure"
@echo " make metrics-open - Open Grafana dashboard in browser (http://localhost:3000)"
@echo ""
@echo "Other:"
@echo " make clean - Clean build artifacts"
@echo " make proto - Initialize snapchain submodule for protobuf files"
@echo " make changelog - Generate changelog"
@echo ""
@echo "Environment Variables:"
@echo " All variables can be defined in .env file or passed on command line"
@echo " REGISTRY - Docker registry (default: $(REGISTRY))"
@echo " IMAGE_NAME - Docker image name (default: $(IMAGE_NAME))"
@echo " TAG - Docker image tag (for docker-tag target)"
@echo " FIDS - Comma-separated list of FIDs (for backfill-queue-fids)"
@echo " MAX_FID - Maximum FID (for backfill-queue-max and backfill-update-user-data-max)"
@echo " FID - Single FID number (for backfill-onchain-fid)"
@echo " EVENT_TYPE - Onchain event type: signer, signer_migrated, id_register, storage_rent, tier_purchase"
@echo " ARGS - Additional command line arguments to pass to the binary"
@echo " PORT - Port to run the service on (default: 8080)"
@echo " See .env.example for all available configuration options"