Skip to content

Commit

Permalink
Olshansk debugging round2 (#10)
Browse files Browse the repository at this point in the history
* Debugging from discord
* Added clean commands
* Running locally, but still trying to figure out usage
* Instructions on using postgres
* Add amd64 and arm64 to build targets on CI to ensure both are properly working.
* Added @Olshansk change on dev-node.dockerfile (dev & test) to node.dockerfile (production)

---------

Co-authored-by: Jorge S. Cuesta <[email protected]>
  • Loading branch information
Olshansk and jorgecuesta authored Jul 30, 2024
1 parent 7885623 commit 932f2b2
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 69 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
file: docker/node.dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
# Added platforms to ensure this image will work on Linux and OSx with Mx processors
platforms: linux/amd64,linux/arm64
build-args: |
CI=true
NODE_ENV=production
Expand All @@ -42,6 +44,8 @@ jobs:
file: docker/dev-node.dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
# Added platforms to ensure this image will work on Linux and OSx with Mx processors
platforms: linux/amd64,linux/arm64
build-args: |
CI=true
NODE_ENV=test
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ Thumbs.db
!.env.sample

.yarn/cache

# Visual Studio
.vscode

55 changes: 44 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ API to the indexed data.

To learn more about SubQuery, [see their docs](https://academy.subquery.network).

- [Docs](#docs)
- [Usage \& Query Docs](#usage--query-docs)
- [Explore via postgres](#explore-via-postgres)
- [Getting Started](#getting-started)
- [tl;dr local development (if not your first time)](#tldr-local-development-if-not-your-first-time)
- [1. Ensure submodules are updated](#1-ensure-submodules-are-updated)
- [2. Install dependencies](#2-install-dependencies)
- [3. Generate types](#3-generate-types)
- [4. Run](#4-run)
- [4.1 Errors running \& building](#41-errors-running--building)
- [Localnet ONLY](#localnet-only)
- [4.1 Debugging, errors running \& building](#41-debugging-errors-running--building)
- [4.2 Using a pre-built image](#42-using-a-pre-built-image)
- [4.3 Available scripts breakdown](#43-available-scripts-breakdown)
- [4.3 Available Scripts breakdown](#43-available-scripts-breakdown)
- [DB Migrations](#db-migrations)
- [Install dependencies](#install-dependencies)
- [Running Migrations](#running-migrations)
Expand All @@ -36,12 +39,36 @@ To learn more about SubQuery, [see their docs](https://academy.subquery.network)
- [End-to-end Testing](#end-to-end-testing)
- [Tracing](#tracing)

## Docs
## Usage & Query Docs

See the [docs](./docs/introduction.md) directory.
See the [introduction docs](./docs/introduction.md) directory for details
on how to use indexed data after you're fully set up.

### Explore via postgres

Connect to the postgres container, update the schema and explore!

```bash
docker exec -it pocketdex_development-postgres-1 psql -U postgres -d postgres
SET search_path TO app;
\dt
```

## Getting Started

### tl;dr local development (if not your first time)

Run the following:

```bash
yarn install
yarn run codegen
docker context use default # Optional
yarn run docker:build:development
yarn poktroll:proxy:start
yarn run docker:start:development
```

### 1. Ensure submodules are updated

```shell
Expand All @@ -68,19 +95,22 @@ Dotenv files will be automatically created after the `yarn install` thanks to th
After that, feel free to modify them as you wish.

You will see three dotenv files, each for the corresponding script and environment:

* `.env.production`
* `.env.development`
* `.env.test`

Alternatively, you can manually create them running:

```shell
yarn run env:prepare
```

For this README we will be running all the commands in `development` but you can also run them in `test` or `production`.
Following this structure, you can run every docker command `docker:<cmd>:<production|development|test>`,

#### Localnet ONLY:
#### Localnet ONLY

```shell
# Run this ONLY IF indexing poktroll localnet.
# This will allows subquery-node to connect with the poktroll validator
Expand All @@ -97,7 +127,7 @@ Build & start:
```shell
# Then build docker and start
yarn run docker:build:development
# This will turn on the process under a WATCHER so any change to the project.ts schema.graphql or src will trigger
# This will turn on the process under a WATCHER so any change to the project.ts schema.graphql or src will trigger
# the needed builds again.
yarn run docker:start:development
```
Expand All @@ -114,15 +144,18 @@ Or Stop & clean up (delete postgres data):
yarn run docker:clean:development
```

#### 4.1 Errors running & building
#### 4.1 Debugging, errors running & building

If you're hitting errors with the above command, try cleaning your cache:
If you're hitting errors with the above command, do a nuclear clean of all potential issues:

```bash
yarn cache clean
yarn vendor:clean
docker builder prune --all
docker context use default
```

And pick up from the `yarn run docker:build` step above
Now pick up from the `yarn run docker:build` step above.

#### 4.2 Using a pre-built image

Expand Down Expand Up @@ -175,7 +208,7 @@ services:
* `docker:start:<environment>` - Starts all services for the specified environment.
* `docker:ps:<environment>` - Shows the status of services for the specified environment.
* `docker:stop:<environment>` - Stops all active services for the specified environment without removing them.
* `docker:clean:<environment>` - Stops and removes all services, volumes, and networks for the specified environment.
* `docker:clean:<environment>` - Stops and removes all services, volumes, and networks for the specified environment.

## DB Migrations

Expand Down
7 changes: 6 additions & 1 deletion docker/dev-node.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ ENV CI=$CI

# typescript is added here because is wrongly used on some of the workspaces, just by the name
# without the use of npm exec, yarn exec or any other to ensure they are looking into the node_modules
RUN apt-get update && apt-get install -y tree git postgresql-client tini curl jq yq && npm i -g typescript
RUN apt-get update \
&& apt-get install -y tree git postgresql-client tini curl jq yq \
# The following was necessary to install in order to add support for building
# the docker container on an M1 chip (i.e. ARM64)
make build-essential pkg-config python3 libusb-1.0-0-dev libudev-dev \
&& npm i -g typescript

WORKDIR /app

Expand Down
6 changes: 5 additions & 1 deletion docker/node.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ ENV CHAIN_ID=$CHAIN_ID

# Typescript is added here because is wrongly used on some of the workspaces, just by the name
# without the use of npm exec, yarn exec or any other to ensure they are looking into the node_modules
RUN apt-get update && apt-get install -y tree && npm i -g typescript
RUN apt-get update && apt-get install -y tree \
# The following was necessary to install in order to add support for building
# the docker container on an M1 chip (i.e. ARM64)
make build-essential pkg-config python3 libusb-1.0-0-dev libudev-dev \
&& npm i -g typescript

WORKDIR /app

Expand Down
Loading

0 comments on commit 932f2b2

Please sign in to comment.