Skip to content

Commit fe4d7b2

Browse files
authored
Dev docs (#146)
* feat: add dag-indexer target to Makefile for building DAG Indexer * feat: add profiles for subspace-node and object-mapping-app in docker-compose * docs: add detailed setup instructions for launching files gateway components * feat: add production profile to subspace-node in docker-compose * docs: add 'Getting Started' section with local development guide to README
1 parent daa9a67 commit fe4d7b2

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ common: models rpc
1010
indexer: common
1111
yarn indexer build
1212

13+
dag-indexer: common
14+
yarn dag-indexer build
15+
1316
file-retriever: common
1417
yarn file-retriever build
1518

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ sequenceDiagram
3535
Gateway->>Node: Retrieve object metadata from the node
3636
```
3737

38+
## Getting Started
39+
40+
- [Local Development Guide](docs/development.md) - Run the gateway locally for development
41+
3842
For a more detailed over on each service check out:
3943

4044
- [File retriever](docs/file-retriever.md)

docker/object-mapping-indexer/docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ volumes:
55
services:
66
subspace-node:
77
image: ${NODE_DOCKER_TAG}
8+
profiles:
9+
- node
10+
- production
811
volumes:
912
- subspace-node-data:/var/subspace:rw
1013
ports:
@@ -39,6 +42,8 @@ services:
3942
image: ${OBJECT_MAPPING_INDEXER_DOCKER_TAG}
4043
container_name: object-mapping-app
4144
working_dir: /app
45+
profiles:
46+
- production
4247
ports:
4348
- '${OBJECT_MAPPING_INDEXER_PORT:-3000}:3000'
4449
environment:

docs/development.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# How to launch files gateway?
2+
3+
As is detailed on [docs](https://github.com/autonomys/auto-files-gateway/), files gateway is a three component system and should be launched in this order:
4+
5+
## 1. Subspace Node
6+
7+
Not essential you can optionally connect a remote RPC though you will have to wait for your published IPLD nodes to be archived.
8+
9+
## 2. Database
10+
11+
Both DAG indexer and object mapping indexer needs a database for storing some data. There you can launch a postgres at: `psql://postgres:postgres@localhost:5432/postgres` by executing the command `docker compose -f docker/object-mapping-indexer/docker-compose.yml --profile development up -d db`
12+
13+
## 3. DAG indexer
14+
15+
This will store the IPLD nodes metadata on a database which enables features like partial file retrieval and speeds up retrieval by not retrieving `Inlink` nodes.
16+
17+
You will have to setup the following `.env` at the root of the repo
18+
19+
```bash
20+
# subquery params
21+
RPC_ENDPOINTS=wss://rpc-0.mainnet.autonomys.xyz/ws # or your local
22+
CHAIN_ID=0x66455a580aabff303720aa83adbe6c44502922251c03ba73686d5245da9e21bd
23+
START_BLOCK=0 # this might fail if node is not in archival mode
24+
25+
# database
26+
DB_USER=postgres
27+
DB_PASSWORD=postgres
28+
DB_DATABASE=postgres
29+
DB_HOST=127.0.0.1
30+
DB_PORT=5432
31+
```
32+
33+
And launch it with:
34+
35+
```bash
36+
make dag-indexer
37+
yarn dag-indexer start
38+
```
39+
40+
## 4. Object Mapping Indexer
41+
42+
For setting up the object mapping indexer, you will need to provide the following config at `services/object-mapping-indexer/.env`
43+
44+
```bash
45+
NODE_RPC_URL=wss://rpc-0.mainnet.autonomys.xyz/ws # or your local
46+
DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres
47+
```
48+
49+
And, for launch it:
50+
51+
```bash
52+
make indexer
53+
yarn indexer start
54+
```
55+
56+
## 5. File Retriever
57+
58+
Finally, the last piece of the files gateway is the file retriever which has the following config at `services/file-retriever/.env`
59+
60+
```bash
61+
SUBSPACE_GATEWAY_URLS=http://localhost:9955
62+
OBJECT_MAPPING_INDEXER_URL=http://localhost:3000
63+
VICTORIA_ACTIVE=false
64+
VICTORIA_ENDPOINT=<victoria-endpoint>
65+
VICTORIA_USERNAME=<victoria-username>
66+
VICTORIA_PASSWORD=<victoria-password>
67+
API_SECRET=random-secret # the apikey needed for file retrieval
68+
CORS_ORIGIN=*
69+
MAX_SIMULTANEOUS_FETCHES=10 # optional
70+
CACHE_DIR=./.cache # optional
71+
CACHE_MAX_SIZE=1024000000 # optional
72+
CACHE_TTL=86400000 # optional
73+
74+
```
75+
76+
And, for launch it:
77+
78+
```bash
79+
make file-retriever
80+
yarn file-retriever start
81+
```
82+
83+
And with that files gateway would be fully deployed locally

0 commit comments

Comments
 (0)