Skip to content

Commit eb2bca3

Browse files
committed
feat(local_network): Enable the gateway service
1 parent c6e84c7 commit eb2bca3

File tree

2 files changed

+109
-19
lines changed

2 files changed

+109
-19
lines changed

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
.PHONY: setup setup-dev reload logs down fmt
1+
.PHONY: setup setup-dev reload logs down fmt help
2+
3+
# Default target shows help
4+
help:
5+
@echo "Available commands:"
6+
@echo " make setup - Full setup for testing (builds and starts all services)"
7+
@echo " make reload - Rebuild binaries and restart services after code changes"
8+
@echo " make logs - Watch log output from services"
9+
@echo " make down - Stop all services and remove containers"
10+
@echo " make fmt - Run cargo fmt"
11+
@echo " make test-local - Run local tests"
12+
@echo ""
13+
@echo "Development workflow:"
14+
@echo " 1. Run 'make setup' to initialize everything"
15+
@echo " 2. After code changes, run 'make reload' to rebuild and restart"
16+
@echo " 3. Use 'make logs' to monitor service logs"
17+
@echo " 4. Run 'make down' to stop all services when done"
218

319
# Full setup for testing
420
# this includes building indexer-service and tap-agent
@@ -18,6 +34,7 @@ logs:
1834
# Stop all services
1935
down:
2036
cd contrib && docker compose -f docker-compose.dev.yml down
37+
docker rm -f indexer-service tap-agent gateway 2>/dev/null || true
2138

2239
# Cargo commands
2340
fmt:

setup-test-network.sh

Lines changed: 91 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
#!/bin/bash
22
set -e
33

4+
# ==============================================================================
5+
# SETUP LOCAL GRAPH NETWORK FOR TESTING
6+
# ==============================================================================
7+
# This script sets up a local Graph network for testing.
8+
#
9+
# NOTES:
10+
# - If you encounter container conflicts, run: docker compose down
11+
# to stop all services before running this script again
12+
#
13+
# - To test changes to your indexer code without restarting everything:
14+
# make reload
15+
#
16+
# - The script checks for existing services and skips those already running
17+
# ==============================================================================
18+
19+
container_running() {
20+
docker ps --format '{{.Names}}' | grep -q "^$1$"
21+
return $?
22+
}
23+
24+
if container_running "indexer-service" && container_running "tap-agent" && container_running "gateway"; then
25+
echo "====================================================================================="
26+
echo "All services are already running. To test changes to your indexer code, you can use:"
27+
echo " make reload - To rebuild and restart just indexer-service tap-agent services"
28+
echo ""
29+
echo "If you need to start from scratch, first stop all services with:"
30+
echo " make down"
31+
echo " docker rm -f indexer-service tap-agent gateway"
32+
echo "====================================================================================="
33+
exit 0
34+
fi
35+
436
cd contrib/
537
ls
638
pwd
@@ -9,7 +41,7 @@ pwd
941
if [ ! -d "local-network" ]; then
1042
git clone https://github.com/edgeandnode/local-network.git
1143
cd local-network
12-
# Chekout to a specific commit that is known to work
44+
# Checkout to a specific commit that is known to work
1345
git checkout 006e2511d4b8262ff14ff6cd5e1b75f0663dee98
1446
cd ..
1547
fi
@@ -65,6 +97,10 @@ docker compose up -d indexer-agent
6597
echo "Waiting for indexer-agent to be healthy..."
6698
timeout 300 bash -c 'until docker ps | grep indexer-agent | grep -q healthy; do sleep 5; done'
6799

100+
docker compose up -d indexer-service
101+
echo "Waiting for indexer-service to be healthy..."
102+
timeout 300 bash -c 'until docker ps | grep indexer-service | grep -q healthy; do sleep 5; done'
103+
68104
echo "Starting subgraph deployment..."
69105
docker compose up --build -d subgraph-deploy
70106
sleep 10 # Give time for subgraphs to deploy
@@ -73,25 +109,23 @@ echo "Starting TAP services..."
73109
echo "Starting tap-aggregator..."
74110
docker compose up -d tap-aggregator
75111
sleep 10
76-
# tap-scrow-manager requires subgraph-deploy
77-
echo "Starting tap-scrow-manager..."
112+
113+
echo "Starting tap-agent..."
114+
docker compose up -d tap-agent
115+
sleep 10
116+
117+
# tap-escrow-manager requires subgraph-deploy
118+
echo "Starting tap-escrow-manager..."
78119
docker compose up -d tap-escrow-manager
79120
sleep 10
80-
# Phase 4: Try a simple escrowAccounts query to see if the schema is accessible
81-
echo "Testing escrowAccounts query..."
82-
curl -s "http://localhost:8000/subgraphs/name/semiotic/tap" \
83-
-H 'content-type: application/json' \
84-
-d '{"query": "{ escrowAccounts { id } }"}'
85-
# docker compose up -d chain ipfs postgres graph-node graph-contracts tap-contracts tap-escrow-manager tap-aggregator
86-
# docker compose up -d chain ipfs postgres graph-node graph-contracts tap-contracts tap-escrow-manager tap-aggregator block-oracle indexer-agent
87-
88-
# # Wait for services to be ready
89-
# echo "Waiting for graph-node to be healthy..."
90-
# timeout 300 bash -c 'until docker ps | grep graph-node | grep -q healthy; do sleep 5; done'
91-
#
92-
# # Check if tap-contracts deployed the subgraph
93-
# echo "Checking if TAP subgraph is deployed..."
94-
# timeout 300 bash -c 'until curl -s "http://localhost:8000/subgraphs/name/semiotic/tap" -H "content-type: application/json" -d "{\"query\": \"{ _meta { block { number } } }\"}" | grep -q "data"; do sleep 5; done'
121+
122+
# Start redpanda if it's not already started (required for gateway)
123+
if ! docker ps | grep -q redpanda; then
124+
echo "Starting redpanda..."
125+
docker compose up -d redpanda
126+
echo "Waiting for redpanda to be healthy..."
127+
timeout 300 bash -c 'until docker ps | grep redpanda | grep -q healthy; do sleep 5; done'
128+
fi
95129

96130
# Get the network name used by local-network
97131
NETWORK_NAME=$(docker inspect graph-node --format='{{range $net,$v := .NetworkSettings.Networks}}{{$net}}{{end}}')
@@ -119,6 +153,45 @@ EOF
119153
echo "Building base Docker image for development..."
120154
docker build -t indexer-base:latest -f base/Dockerfile ..
121155

156+
# Check to stop any previous instance of indexer-service
157+
# and tap-service
158+
echo "Checking for existing conflicting services..."
159+
if docker ps | grep -q "indexer-service\|tap-agent"; then
160+
echo "Stopping existing indexer-service or tap-agent containers..."
161+
docker stop indexer-service tap-agent 2>/dev/null || true
162+
docker rm indexer-service tap-agent 2>/dev/null || true
163+
fi
164+
122165
# Run the custom services using the override file
123166
docker compose -f docker-compose.yml -f docker-compose.override.yml up --build -d
124167
rm docker-compose.override.yml
168+
169+
# GATEWAY DEPLOYMENT NOTE:
170+
# We're deploying gateway directly with "docker run" instead of docker-compose
171+
# because the local-network's compose file has a dependency on "indexer-service",
172+
# which would conflict with our custom indexer-service container.
173+
# This approach avoids container name conflicts while allowing full testing
174+
# of the RAV flow through the gateway.
175+
echo "Building gateway image..."
176+
docker build -t local-gateway:latest ./local-network/gateway
177+
178+
echo "Running gateway container..."
179+
docker run -d --name gateway \
180+
--network local-network_default \
181+
-p 7700:7700 \
182+
-v $(pwd)/local-network/.env:/opt/.env:ro \
183+
-v $(pwd)/local-network/contracts.json:/opt/contracts.json:ro \
184+
-e RUST_LOG=info,graph_gateway=trace \
185+
--restart on-failure:3 \
186+
local-gateway:latest
187+
188+
echo "Waiting for gateway to be healthy..."
189+
if docker ps | grep -q "gateway"; then
190+
echo "Gateway is running"
191+
else
192+
echo "Gateway failed to start. Check logs with: docker logs gateway"
193+
exit 1
194+
fi
195+
196+
echo "All services are now running!"
197+
echo "You can enjoy your new local network setup for testing."

0 commit comments

Comments
 (0)