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

feat: local deployment #26

Merged
merged 15 commits into from
Nov 8, 2024
Merged
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
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ignore all .env files in any directory or subdirectory
**/.env

# Ignore node_modules and dist directories in any directory or subdirectory
**/node_modules
**/dist

**/.git
**/.turbo
**/*.md
47 changes: 33 additions & 14 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@
######################################################
DATALAYER_POSTGRES_PASSWORD=testing
DATALAYER_PG_USER=postgres
DATALAYER_PG_DATABASE=datalayer-postgres
DATALAYER_PG_DATABASE=datalayer-postgres-db
DATALAYER_POSTGRES_EXPOSED_PORT=5434

######################################################
############### DATALAYER HASURA API #################
######################################################
#for reference on Hasura configuration, see: https://hasura.io/docs/2.0/deployment/graphql-engine-flags/reference/
DATALAYER_HASURA_EXPOSED_PORT=8082
DATALAYER_HASURA_ENABLE_CONSOLE=true
DATALAYER_HASURA_ADMIN_SECRET=my-admin-secret
DATALAYER_HASURA_UNAUTHORIZED_ROLE=public
DATALAYER_HASURA_ENABLE_CONSOLE="true"
DATALAYER_HASURA_ADMIN_SECRET="my-admin-secret"
DATALAYER_HASURA_UNAUTHORIZED_ROLE="public"
DATALAYER_HASURA_CORS_DOMAIN=*
DATALAYER_HASURA_ENABLE_TELEMETRY=false
# HASURA_GRAPHQL_METADATA_DATABASE_EXTENSIONS_SCHEMA: "chain_data_schema_1"
DATALAYER_HASURA_ENABLE_TELEMETRY="false"
## enable debugging mode. It is recommended to disable this in production
DATALAYER_HASURA_DEV_MODE=true
DATALAYER_HASURA_ADMIN_INTERNAL_ERRORS=true
DATALAYER_HASURA_DEV_MODE="true"
DATALAYER_HASURA_ADMIN_INTERNAL_ERRORS="true"
## uncomment next line to run console offline (i.e load console assets from server instead of CDN)
# HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets
# DATALAYER_HASURA_CONSOLE_ASSETS_DIR="/srv/console-assets"

############################################################
############### ENVIO POSTGRES & INDEXER ###################
Expand All @@ -38,20 +36,41 @@ ENVIO_POSTGRES_EXPOSED_PORT=5433
############################################
############### INDEXER ####################
############################################
ENVIO_PG_HOST=envio-postgres
ENVIO_PG_HOST=indexer-postgres-db
ENVIO_PG_PORT=5432
HASURA_GRAPHQL_ENDPOINT=http://graphql-engine:8080/v1/metadata
HASURA_GRAPHQL_ENDPOINT=http://indexer-graphql-api:8080/v1/metadata
TUI_OFF=true

############################################
############### HASURA #####################
############################################
HASURA_EXPOSED_PORT=8080
HASURA_GRAPHQL_DATABASE_URL=postgres://postgres:testing@envio-postgres:5432/envio-dev
HASURA_GRAPHQL_DATABASE_URL=postgres://postgres:testing@indexer-postgres-db:5432/envio-dev
HASURA_GRAPHQL_ENABLE_CONSOLE=true
HASURA_GRAPHQL_ENABLED_LOG_TYPES=startup, http-log, webhook-log, websocket-log, query-log
HASURA_GRAPHQL_NO_OF_RETRIES=10
HASURA_GRAPHQL_ADMIN_SECRET=testing
HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES="true"
PORT=8080
HASURA_GRAPHQL_UNAUTHORIZED_ROLE=public
HASURA_GRAPHQL_UNAUTHORIZED_ROLE=public

############################################
############### PROCESSING #################
############################################

RPC_URLS=["https://optimism.llamarpc.com","https://rpc.ankr.com/optimism","https://optimism.gateway.tenderly.co","https://optimism.blockpi.network/v1/rpc/public","https://mainnet.optimism.io","https://opt-mainnet.g.alchemy.com/v2/demo"]
CHAIN_ID=10

FETCH_LIMIT=1000
FETCH_DELAY_MS=3000

DATABASE_URL=postgresql://postgres:testing@datalayer-postgres-db:5432/datalayer-postgres-db
DATABASE_SCHEMA=chain_data_schema_1

INDEXER_GRAPHQL_URL=http://indexer-graphql-api:8080/v1/graphql
INDEXER_ADMIN_SECRET=testing

IPFS_GATEWAYS_URL=["https://ipfs.io","https://gateway.pinata.cloud","https://dweb.link", "https://ipfs.eth.aragon.network"]

COINGECKO_API_KEY={{YOUR_KEY}}
COINGECKO_API_TYPE=demo
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Based on example:
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

FROM base AS build
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run -r build
RUN pnpm deploy --filter=./apps/processing --prod /prod/processing

FROM base AS processing
COPY --from=build /prod/processing /prod/processing
WORKDIR /prod/processing
CMD [ "pnpm", "start" ]
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This repository is a monorepo that contains 1 package and 2 applications:
- @ts-turborepo-boilerplate/sample-app: A demo application demonstrating the use of sample-lib.
- @grants-stack-indexer/indexer: An [`envio`](https://docs.envio.dev/) indexer, that collects all the relevant events from Allo contracts.

## 🚀 Local Deployment (Dockerized)
## 🚀 Local Deployment (Development)

### Prerequisites

Expand All @@ -19,15 +19,39 @@ Ensure you have the following installed on your machine:
- [Docker](https://www.docker.com/get-started)
- [Docker Compose](https://docs.docker.com/compose/install/)

### Run
### Setup

To deploy locally with Docker, run the following command:
1. Copy the Example Environment File and edit the `.env` file

```
cp .env.example .env
```

2. Build and start the services in detached mode:

```
docker-compose up -d --build
```

Once the deployment is complete, you can access Hasura by navigating to:
3. Copy the Example Environment File on `apps/migration-scripts` and edit the `.env` file

```
cp apps/migration-scripts/.env.example apps/migration-scripts/.env
```

4. After starting Docker Compose, run the following command to apply the database migrations:

```
pnpm script:db:migrate
```

5. Navigate to the processing service directory and start it with:

```
cd apps/processing && pnpm dev
```

Once the setup is completed you can access Hasura by navigating to:

```
http://localhost:8080/
Expand Down
2 changes: 1 addition & 1 deletion apps/indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"chai": "4.3.10",
"envio": "2.7.2",
"envio": "2.7.3",
"ethers": "6.8.0",
"yaml": "2.5.1"
},
Expand Down
51 changes: 26 additions & 25 deletions apps/indexer/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions apps/processing/.env.example
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# configuration for Optimism
RPC_URLS=["https://optimism.llamarpc.com","https://rpc.ankr.com/optimism","https://optimism.gateway.tenderly.co","https://optimism.blockpi.network/v1/rpc/public","https://mainnet.optimism.io","https://opt-mainnet.g.alchemy.com/v2/demo"]
CHAIN_ID=10
LOG_LEVEL=debug

FETCH_LIMIT=500
FETCH_DELAY_MS=3000
FETCH_LIMIT=10000
FETCH_DELAY_MS=30000

DATABASE_URL=
DATABASE_SCHEMA=chainDataSchema
DATABASE_URL=postgresql://postgres:testing@localhost:5434/datalayer-postgres-db
DATABASE_SCHEMA=chain_data_schema_1

INDEXER_GRAPHQL_URL=
INDEXER_ADMIN_SECRET=
INDEXER_GRAPHQL_URL=http://localhost:8080/v1/graphql
INDEXER_ADMIN_SECRET=testing

IPFS_GATEWAYS_URL=["https://ipfs.io","https://gateway.pinata.cloud","https://dweb.link", "https://ipfs.eth.aragon.network"]

COINGECKO_API_KEY=
COINGECKO_API_TYPE= #demo or pro
COINGECKO_API_KEY={{YOUR_KEY}}
COINGECKO_API_TYPE=demo
2 changes: 2 additions & 0 deletions apps/scripts/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DATABASE_URL=postgres://postgres:testing@localhost:5434/datalayer-postgres-db
DATABASE_SCHEMA=chain_data_schema_1
Loading