Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always instruct people to run indexer in docker #658

Merged
merged 3 commits into from
Oct 12, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ This command will:

Sign up for [Neon postgres](https://neon.tech/) which is our cloud Postgres provider and create a new project. Find the connection string in Neon console's quickstart section, it should look like `postgresql://username:password@host/neondb?sslmode=require` and set it in the `.env` file as `DATABASE_URL`.

If you want to run the database locally, you can follow [this tutorial](https://www.docker.com/blog/how-to-use-the-postgres-docker-official-image/) to run a postgres database in a docker container.

### Setup the database

<Callout>
Expand Down Expand Up @@ -92,18 +94,24 @@ diesel migration generate create-abc-table \

Sign up for [Aptos Build](https://developers.aptoslabs.com/), create a new project and get the API token.

### Run the custom indexer locally
### Build the docker image locally and run the container locally

In the `indexer` folder, make a copy of `example.config.yaml` and rename it to `config.yaml`. Fill in the following:
- `starting_version`: The tx version (Aptos concept, similar to block height) from which you want to start indexing
- `postgres_connection_string`: The connection string of the postgres database, DO NOT include the `?sslmode=require` because diesel doesn't recognize it correctly, instead we handle it in the code
- `contract_address`: The address of the Move contract
- `auth_token`: Aptos Build API token

Start the custom indexer locally:
Build the docker image targeting linux/amd64 as we will eventually push the image to Artifact Registry and deploy it to Cloud Run, which only supports linux/amd64.

```bash filename="Terminal"
docker build --platform linux/amd64 -t indexer .
```

You can run the docker container locally to make sure it works. Mac supports linux/amd64 emulation so you can run the x86 docker image on Mac.

```bash filename="Terminal"
cargo run --release -- -c config.yaml
docker run -p 8080:8080 -it indexer
```

### Run the frontend
Expand Down Expand Up @@ -172,20 +180,6 @@ If you are looking for different services to deploy the static site to, `create-

We recommend using Google Cloud Run to host the indexer, Secret Manager to store `config.yaml` and Artifact Registry to store the indexer docker image.

### Build the docker image locally and run the container locally

Build the docker image targeting linux/amd64 as we will eventually push the image to Artifact Registry and deploy it to Cloud Run, which only supports linux/amd64.

```bash filename="Terminal"
docker build --platform linux/amd64 -t indexer .
```

You can run the docker container locally to make sure it works. Mac supports linux/amd64 emulation so you can run the x86 docker image on Mac.

```bash filename="Terminal"
docker run -p 8080:8080 -it indexer
```

### Push the locally build docker image to Artifact Registry

Login to google cloud
Expand Down
Loading