Skip to content

Commit 7ffbc98

Browse files
sameh-faroukclaude
andcommitted
chore: update compose stacks and shared networking
- Upgrade PostgreSQL 16 -> 17 - Upgrade CockroachDB v22.2.2 -> v22.2.15 - Upgrade substrate-gateway 2.5.0 -> 2.7.0 - Rename indexer CockroachDB service from 'db' to 'cockroachdb' to avoid DNS collision when both stacks share a Docker network - Add shared external network 'tfgrid_bknd' to both compose files so the processor can reach the indexer gateway by service name - Update INDEXER_ENDPOINT_URL default to http://gateway:8000/graphql (Docker service name) instead of localhost:8888 (host port mapping) - Remove obsolete 'version' field from both compose files - Update production docs with shared network setup and env var changes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2a3a713 commit 7ffbc98

5 files changed

Lines changed: 35 additions & 23 deletions

File tree

.env

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
DB_NAME=tfgrid-graphql
22
DB_USER=postgres
33
DB_PASS=postgres
4-
#DB_HOST=172.17.0.1
54
DB_PORT=5432
65
TYPEORM_LOGGING=error
7-
INDEXER_ENDPOINT_URL=http://localhost:8888/graphql
8-
WS_URL=ws://localhost:9944
6+
# For Docker deployment (shared tfgrid_bknd network): use gateway service name
7+
# For local development outside Docker: use http://localhost:8888/graphql
8+
INDEXER_ENDPOINT_URL=http://gateway:8000/graphql
9+
WS_URL=wss://tfchain.dev.grid.tf/ws

docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
version: "3.4"
1+
networks:
2+
default:
3+
name: tfgrid_bknd
4+
external: true
25

36
services:
47
db:
5-
image: postgres:16
8+
image: postgres:17
69
restart: always
710
ports:
811
- "${DB_PORT}:5432"

docs/production.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ The production stack has two independent layers:
1515

1616
## Run the Setup
1717

18+
Both compose stacks share a Docker network (`tfgrid_bknd`) so the processor can reach the indexer gateway by service name. Create it before starting either stack:
19+
20+
```bash
21+
docker network create tfgrid_bknd
22+
```
23+
1824
### 1. Indexer
1925

2026
Configure `indexer/.env`:
@@ -41,8 +47,8 @@ Configure `.env` in the project root:
4147
| `DB_USER` | PostgreSQL user | `postgres` |
4248
| `DB_PASS` | PostgreSQL password | `postgres` |
4349
| `DB_PORT` | PostgreSQL port | `5432` |
44-
| `INDEXER_ENDPOINT_URL` | Indexer GraphQL gateway URL | `http://localhost:8888/graphql` |
45-
| `WS_URL` | TFChain node WebSocket URL (used for RPC calls) | `ws://localhost:9944` |
50+
| `INDEXER_ENDPOINT_URL` | Indexer GraphQL gateway URL. Use `http://gateway:8000/graphql` for Docker (shared network), `http://localhost:8888/graphql` for local dev | `http://gateway:8000/graphql` |
51+
| `WS_URL` | TFChain node WebSocket URL (used for RPC calls) | `wss://tfchain.dev.grid.tf/ws` |
4652
| `TYPEORM_LOGGING` | TypeORM log level | `error` |
4753

4854
```bash

indexer/docker-compose.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
version: "3.8"
1+
networks:
2+
default:
3+
name: tfgrid_bknd
4+
external: true
25

36
services:
4-
db:
5-
image: cockroachdb/cockroach:v22.2.2
7+
cockroachdb:
8+
image: cockroachdb/cockroach:v22.2.15
69
restart: always
710
ports:
811
- "26257:26257"
@@ -11,20 +14,19 @@ services:
1114
volumes:
1215
- /cockroach/cockroach-data
1316

14-
db-init:
17+
cockroachdb-init:
1518
depends_on:
16-
- db
17-
image: cockroachdb/cockroach:v22.2.2
18-
19+
- cockroachdb
20+
image: cockroachdb/cockroach:v22.2.15
1921
volumes:
2022
- ./setup_db.sh:/setup_db.sh
2123
entrypoint: "/bin/bash"
2224
command: /setup_db.sh
2325
restart: on-failure
24-
26+
2527
ingest:
2628
depends_on:
27-
db-init:
29+
cockroachdb-init:
2830
condition: service_completed_successfully
2931
restart: on-failure
3032
image: subsquid/substrate-ingest:1
@@ -37,7 +39,7 @@ services:
3739
"-c",
3840
"20",
3941
"--out",
40-
"postgres://root@db:26257/defaultdb",
42+
"postgres://root@cockroachdb:26257/defaultdb",
4143
"--types-bundle",
4244
"/configs/typesBundle.json",
4345
"--start-block",
@@ -46,24 +48,24 @@ services:
4648

4749
gateway:
4850
depends_on:
49-
db-init:
51+
cockroachdb-init:
5052
condition: service_completed_successfully
51-
image: subsquid/substrate-gateway:2.5.0
53+
image: subsquid/substrate-gateway:2.7.0
5254
environment:
5355
DATABASE_MAX_CONNECTIONS: 5
5456
RUST_LOG: "actix_web=info,actix_server=info"
55-
command: [ "--database-url", "postgres://root@db:26257/defaultdb" ]
57+
command: [ "--database-url", "postgres://root@cockroachdb:26257/defaultdb" ]
5658
ports:
5759
- "8888:8000"
5860

5961
explorer:
6062
depends_on:
61-
db-init:
63+
cockroachdb-init:
6264
condition: service_completed_successfully
6365
image: subsquid/substrate-explorer:firesquid
6466
environment:
6567
DB_TYPE: cockroach
66-
DB_HOST: db
68+
DB_HOST: cockroachdb
6769
DB_PORT: "26257"
6870
DB_NAME: "defaultdb"
6971
DB_USER: "root"

indexer/setup_db.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sleep 2
33
echo "Set sql.conn.max_read_buffer_message_size to 32 MiB"
44

5-
HOSTPARAMS="--host db --insecure"
5+
HOSTPARAMS="--host cockroachdb --insecure"
66
SQL="/cockroach/cockroach.sh sql $HOSTPARAMS"
77

88
# https://github.com/threefoldtech/tfchain_graphql/issues/130#issuecomment-1689987550

0 commit comments

Comments
 (0)