generated from eldargab/hydra-template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from ma-shulgin/v5
Migration to V5
- Loading branch information
Showing
67 changed files
with
15,507 additions
and
5,822 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/.git | ||
/node_modules | ||
/lib | ||
/*Versions.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,3 @@ | ||
########################### | ||
# Common settings # | ||
########################### | ||
|
||
# DB config | ||
DB_NAME=hydra | ||
DB_USER=postgres | ||
DB_PASS=postgres | ||
DB_HOST=localhost | ||
DB_PORT=27364 | ||
DEBUG=index-builder:* | ||
TYPEORM_LOGGING=error | ||
|
||
# Chain node address (for typegen or indexer) | ||
CHAIN_NODE=wss://kusama-rpc.polkadot.io | ||
|
||
########################### | ||
# Processor options # | ||
########################### | ||
|
||
# Indexer GraphQL API endpoint to fetch indexed events | ||
INDEXER_ENDPOINT_URL=https://kusama.indexer.gc.subsquid.io/v4/graphql | ||
|
||
# use url below for self-hosted indexer defined in indexer/docker-compose.yml | ||
# INDEXER_ENDPOINT_URL=http://localhost:8080/v1/graphql | ||
|
||
BATCH_SIZE=500 | ||
BLOCK_WINDOW=100000 | ||
|
||
########################### | ||
# GraphQL server # | ||
########################### | ||
|
||
GRAPHQL_SERVER_PORT=4000 | ||
DB_NAME=squid | ||
DB_PORT=23798 | ||
GQL_PORT=4350 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/node_modules | ||
/lib | ||
.DS_Store | ||
kusamaVersions.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "pwa-node", | ||
"request": "launch", | ||
"name": "Launch Program", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"program": "${workspaceFolder}/src/processor.ts", | ||
"runtimeArgs": [ | ||
"--require=dotenv/config" | ||
], | ||
"preLaunchTask": "tsc: build - tsconfig.json", | ||
"outFiles": [ | ||
"${workspaceFolder}/lib/**/*.js" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
FROM node:14 AS builder | ||
WORKDIR /hydra-build | ||
FROM node:16-alpine AS node | ||
|
||
FROM node AS node-with-gyp | ||
RUN apk add g++ make python3 | ||
|
||
FROM node-with-gyp AS builder | ||
WORKDIR /squid | ||
ADD package.json . | ||
ADD package-lock.json . | ||
RUN npm ci | ||
ADD tsconfig.json . | ||
ADD src src | ||
RUN npm run build | ||
|
||
|
||
FROM node:14 AS processor | ||
WORKDIR /hydra-project | ||
FROM node-with-gyp AS deps | ||
WORKDIR /squid | ||
ADD package.json . | ||
ADD package-lock.json . | ||
RUN npm ci # TODO: --production | ||
COPY --from=builder /hydra-build/lib lib | ||
RUN npm ci --production | ||
|
||
FROM node AS squid | ||
WORKDIR /squid | ||
COPY --from=deps /squid/package.json . | ||
COPY --from=deps /squid/package-lock.json . | ||
COPY --from=deps /squid/node_modules node_modules | ||
COPY --from=builder /squid/lib lib | ||
ADD db db | ||
ADD manifest.yml . | ||
ADD schema.graphql . | ||
ADD .env . | ||
# TODO: use shorter PROMETHEUS_PORT | ||
ENV PROCESSOR_PROMETHEUS_PORT 3000 | ||
EXPOSE 3000 | ||
EXPOSE 4000 | ||
|
||
|
||
FROM squid AS processor | ||
CMD ["npm", "run", "processor:start"] | ||
|
||
|
||
FROM processor AS query-node | ||
CMD ["node", "./lib/generated/server.js"] | ||
FROM squid AS query-node | ||
CMD ["npm", "run", "query-node:start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
process: build | ||
@node -r dotenv/config lib/processor.js | ||
|
||
|
||
serve: | ||
@npx squid-graphql-server | ||
|
||
reset: | ||
@npx sqd db drop | ||
@npx sqd db create | ||
@npx sqd db:migrate | ||
|
||
migrate: | ||
@npx sqd db:migrate | ||
|
||
|
||
migration: | ||
@npx sqd db:create-migration Data | ||
|
||
|
||
build: | ||
@npm run build | ||
|
||
|
||
codegen: | ||
@npx sqd codegen | ||
|
||
|
||
typegen: kusamaVersions.json | ||
@npx squid-substrate-typegen typegen.json | ||
|
||
|
||
kusamaVersions.json: | ||
@make explore | ||
|
||
|
||
explore: | ||
@npx squid-substrate-metadata-explorer \ | ||
--chain wss://kusama-rpc.polkadot.io \ | ||
--archive https://kusama.indexer.gc.subsquid.io/v4/graphql \ | ||
--out kusamaVersions.json | ||
|
||
|
||
up: | ||
@docker-compose up -d | ||
|
||
|
||
down: | ||
@docker-compose down | ||
|
||
|
||
.PHONY: process serve start codegen migration migrate up down reset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require('dotenv/config') | ||
|
||
const ormconfig = { | ||
type: 'postgres', | ||
// entities: [require.resolve('../lib/model')], | ||
entities: [], | ||
migrations: [__dirname + '/migrations/*.js'], | ||
synchronize: false, | ||
migrationsRun: false, | ||
dropSchema: false, | ||
logging: ["query", "error", "schema"], | ||
host: process.env.DB_HOST || 'localhost', | ||
port: process.env.DB_PORT ? parseInt(process.env.DB_PORT) : 5432, | ||
database: process.env.DB_NAME || 'postgres', | ||
username: process.env.DB_USER || 'postgres', | ||
password: process.env.DB_PASS || 'postgres' | ||
} | ||
|
||
require('typeorm').createConnection(ormconfig).then(async con => { | ||
try { | ||
await con.runMigrations({transaction: 'all'}) | ||
} finally { | ||
await con.close().catch(err => null) | ||
} | ||
}).then( | ||
() => process.exit(), | ||
err => { | ||
console.error(err) | ||
process.exit(1) | ||
} | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.