11#! /bin/bash
22set -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+
436cd contrib/
537ls
638pwd
941if [ ! -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 ..
1547fi
@@ -65,6 +97,10 @@ docker compose up -d indexer-agent
6597echo " Waiting for indexer-agent to be healthy..."
6698timeout 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+
68104echo " Starting subgraph deployment..."
69105docker compose up --build -d subgraph-deploy
70106sleep 10 # Give time for subgraphs to deploy
@@ -73,25 +109,23 @@ echo "Starting TAP services..."
73109echo " Starting tap-aggregator..."
74110docker compose up -d tap-aggregator
75111sleep 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..."
78119docker compose up -d tap-escrow-manager
79120sleep 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
97131NETWORK_NAME=$( docker inspect graph-node --format=' {{range $net,$v := .NetworkSettings.Networks}}{{$net}}{{end}}' )
119153echo " Building base Docker image for development..."
120154docker 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
123166docker compose -f docker-compose.yml -f docker-compose.override.yml up --build -d
124167rm 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