Skip to content

Commit

Permalink
feat: adding fullnode x docker compose example (MystenLabs#9637)
Browse files Browse the repository at this point in the history
## Description 

This is a docker compose configuration and some instructions for running
the fullnode+indexer+Pg locally on a desktop/laptop.

## Test Plan 

Just verified it starts up and catches up with the network epoch.
  • Loading branch information
allan-bailey authored Mar 22, 2023
1 parent 0e5dfca commit d0e0f68
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docker/fullnode-x/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

0. Build the containers locally to your desktop/laptop with:
- `docker compose build`
- The build process can take a while to complete.

1. First start postgres so you can create the DB with the `diesel` command:
- `docker compose up postgres -d`
* **Note** that postgres will store its db data in `./postgres/data`
- `psql -U postgres -p 5432 -h localhost -c 'create database sui_indexer_testnet'`
- run these in sui.git/crates/sui-indexer:
* `diesel setup --database-url=postgres://postgres:admin@localhost:5432/sui_indexer_testnet`

2. Copy the fullnode.yaml and genesis.blob files for the network to use and put them in the `fullnode/config/` folder.

3. `docker compose up fullnode -d`
- verify it's working by watching the logs with `docker compose logs fullnode -f`

4. Once the full node is working, then start indexer with: `docker compose up indexer -d`

- You will see the indexer catching up checkpoint by checkpoint until it's up to date and ready to serve requests.
`docker compose logs indexer | tail -30`
64 changes: 64 additions & 0 deletions docker/fullnode-x/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
version: "3.9"

services:

fullnode:
build:
context: ../..
dockerfile: ./docker/sui-node/Dockerfile
args:
# update with git sha of whichever branch you're building on.
GIT_REVISION: db24658bc9
BUILD_DATE: today

environment:
- LD_PRELOAD
- RUST_JSON_LOG="true"
- RUST_LOG="info"
# don't use debug, it generates volumes of data.
image: sui-node:latest
command: /opt/sui/entry.sh
restart: unless-stopped
# populate your local ./fullnode/config/ directory with fullnode.yaml and genesis.blob for the network you want to use.
volumes:
- ./fullnode:/opt/sui
ports:
- 9000
- 9184
- target: 8084
published: 8084
protocol: udp

indexer:
build:
context: ../..
dockerfile: ./docker/sui-indexer/Dockerfile
image: sui-indexer:latest
command: /opt/sui/indexer.sh
restart: unless-stopped
volumes:
- ./indexer:/opt/sui
environment:
- RUST_LOG="info"
- RUST_JSON_LOG="true"
- DATABASE_URL=postgres://postgres:admin@postgres:5432/sui_indexer_testnet
- RPC_CLIENT_URL=http://fullnode:9000
ports:
- target: 9000
published: 9000
protocol: tcp
- 9184
depends_on:
- postgres
- fullnode

postgres:
image: postgres:15
restart: unless-stopped
environment:
- POSTGRES_PASSWORD=admin
ports:
- target: 5432
published: 5432
volumes:
- ./postgres/data:/var/lib/postgresql/data
Empty file.
8 changes: 8 additions & 0 deletions docker/fullnode-x/fullnode/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Copyright (c) Mysten Labs, Inc.
# SPDX-License-Identifier: Apache-2.0

unset LD_PRELOAD

/usr/local/bin/sui-node --config-path /opt/sui/config/fullnode.yaml

5 changes: 5 additions & 0 deletions docker/fullnode-x/indexer/indexer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# Copyright (c) Mysten Labs, Inc.
# SPDX-License-Identifier: Apache-2.0

/usr/local/bin/sui-indexer --db-url ${DATABASE_URL} --rpc-client-url ${RPC_CLIENT_URL}
Empty file.

0 comments on commit d0e0f68

Please sign in to comment.