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

WIP - trying to resolve local issues #9

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ To learn more about SubQuery, [see their docs](https://academy.subquery.network)
- [2. Install dependencies](#2-install-dependencies)
- [3. Generate types](#3-generate-types)
- [4. Run](#4-run)
- [Localnet ONLY](#localnet-only)
- [4.1 Errors running \& building](#41-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 Down Expand Up @@ -68,19 +69,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`

- `.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 +101,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 Down Expand Up @@ -175,7 +179,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
5 changes: 4 additions & 1 deletion docker/dev-node.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ 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 libusb-1.0-0.dev tree git build-essential pkg-config postgresql-client tini curl jq yq && npm i -g typescript

# Install node-gyp globally
RUN npm install -g node-gyp

WORKDIR /app

Expand Down
19 changes: 13 additions & 6 deletions scripts/prepare-dotenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@ set -e

# Check if .env.sample exists
if [ ! -f .env.sample ]; then
warning_log ".env.sample does not exist. Skipping automatic dotenv files creation"
warning_log ".env.sample does not exist. Skipping automatic dotenv files creation"
else
# Define environments
environments="development production test"

for environment in $environments
do
# Create a copy of .env.sample for each environment
cp .env.sample .env.$environment
for environment in $environments; do
# Create a copy of .env.sample for each environment
cp .env.sample .env.$environment

# Replace ENV= with ENV=<environment> in each file
# Replace ENV= with ENV=<environment> in each file
if [[ "$OSTYPE" == "darwin"* ]]; then
# NB: sed works differently on macOS so we require that the user has gsed installed.
# This is meant to fail and the expectation is that a user of this framework
# will find this line / comment and install it.
gsed -i "s/^ENV=.*$/ENV=$environment/g" .env.$environment
else
sed -i "s/^ENV=.*$/ENV=$environment/g" .env.$environment
fi

done
fi