-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: simvalery <[email protected]>
- Loading branch information
Showing
157 changed files
with
51,277 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.dockerignore | ||
.env | ||
.git | ||
.gitignore | ||
.npmrc | ||
dist | ||
Dockerfile | ||
node_modules | ||
npm-debug.log |
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,2 @@ | ||
GUARDIAN_ENV="" | ||
#OVVERRIDE="false" |
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,2 @@ | ||
/node_modules/ | ||
/dist/ |
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,61 @@ | ||
# syntax=docker/dockerfile:1 | ||
# Stage 0: Use node image for base image for all stages | ||
ARG NODE_VERSION=20.18-alpine | ||
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS base | ||
WORKDIR /usr/local/app | ||
# Define an argument `YARN_CACHE_FOLDER` for the Yarn cache directory | ||
ARG YARN_CACHE_FOLDER=/root/.yarn | ||
|
||
# Stage 1: Build interfaces module | ||
FROM base AS interfaces | ||
COPY --link interfaces/package.json interfaces/tsconfig*.json yarn.lock ./ | ||
# Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds | ||
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \ | ||
yarn install --immutable | ||
COPY --link interfaces/src src/ | ||
RUN yarn pack | ||
|
||
# Stage 2: Build common module | ||
FROM base AS common | ||
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz | ||
COPY --link common/package.json common/tsconfig*.json yarn.lock ./ | ||
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));" | ||
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \ | ||
yarn install | ||
COPY --link common/src src/ | ||
RUN yarn pack | ||
|
||
# Stage 3: Installing production dependecies | ||
FROM base AS deps | ||
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz | ||
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz | ||
COPY --link api-gateway/package.json api-gateway/tsconfig*.json api-gateway/Gulpfile.mjs yarn.lock ./ | ||
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; input.dependencies['@guardian/common']='file:/tmp/common.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));" | ||
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \ | ||
yarn install --prod | ||
|
||
# Stage 4: Build service | ||
FROM base AS build | ||
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz | ||
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz | ||
COPY --link --from=deps /usr/local/app/package.json /usr/local/app/tsconfig*.json /usr/local/app/Gulpfile.mjs /usr/local/app/yarn.lock ./ | ||
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \ | ||
yarn install --immutable | ||
COPY --link api-gateway/environments environments/ | ||
COPY --link api-gateway/src src/ | ||
RUN yarn run build:prod | ||
|
||
# Stage 5: Create the final image | ||
FROM node:${NODE_VERSION} AS image | ||
WORKDIR /usr/local/app | ||
ENV NODE_ENV=production | ||
|
||
# Copy the production dependencies from the deps stage and the built application from the build stage into the image | ||
COPY --link --from=deps /usr/local/app/node_modules node_modules/ | ||
COPY --link --from=deps /usr/local/app/package.json ./ | ||
COPY --link --from=build /usr/local/app/dist dist/ | ||
|
||
# Change the user to node | ||
USER node | ||
|
||
CMD [ "node", "dist/index.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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# syntax=docker/dockerfile:1 | ||
# Stage 0: Use node image for base image for all stages | ||
ARG NODE_VERSION=20.18-alpine | ||
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS base | ||
WORKDIR /usr/local/app | ||
# Define an argument `YARN_CACHE_FOLDER` for the Yarn cache directory | ||
ARG YARN_CACHE_FOLDER=/root/.yarn | ||
|
||
# Stage 1: Build interfaces module | ||
FROM base AS interfaces | ||
COPY --link interfaces/package.json interfaces/tsconfig*.json yarn.lock ./ | ||
# Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds | ||
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \ | ||
yarn install --immutable | ||
COPY --link interfaces/src src/ | ||
RUN yarn pack | ||
|
||
# Stage 2: Build common module | ||
FROM base AS common | ||
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz | ||
COPY --link common/package.json common/tsconfig*.json yarn.lock ./ | ||
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));" | ||
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \ | ||
yarn install | ||
COPY --link common/src src/ | ||
RUN yarn pack | ||
|
||
# Stage 3: Installing production dependecies | ||
FROM base AS deps | ||
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz | ||
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz | ||
COPY --link api-gateway/package.json api-gateway/tsconfig*.json api-gateway/Gulpfile.mjs yarn.lock ./ | ||
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; input.dependencies['@guardian/common']='file:/tmp/common.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));" | ||
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \ | ||
yarn install --prod | ||
|
||
# Stage 4: Build service | ||
FROM base AS build | ||
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz | ||
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz | ||
COPY --link --from=deps /usr/local/app/package.json /usr/local/app/tsconfig*.json /usr/local/app/Gulpfile.mjs /usr/local/app/yarn.lock ./ | ||
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \ | ||
yarn install --immutable | ||
COPY --link api-gateway/environments environments/ | ||
COPY --link api-gateway/src src/ | ||
RUN yarn run build:demo | ||
|
||
# Stage 5: Create the final image | ||
FROM node:${NODE_VERSION} AS image | ||
WORKDIR /usr/local/app | ||
ENV NODE_ENV=production | ||
|
||
# Copy the production dependencies from the deps stage and the built application from the build stage into the image | ||
COPY --link --from=deps /usr/local/app/node_modules node_modules/ | ||
COPY --link --from=deps /usr/local/app/package.json ./ | ||
COPY --link --from=build /usr/local/app/dist dist/ | ||
|
||
# Change the user to node | ||
USER node | ||
|
||
CMD [ "node", "dist/index.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict' | ||
|
||
import gulp from 'gulp'; | ||
import ts from 'gulp-typescript'; | ||
import rename from 'gulp-rename'; | ||
import sourcemaps from 'gulp-sourcemaps'; | ||
|
||
gulp.task('configure:demo', () => { | ||
return gulp | ||
.src('environments/environment.demo.ts') | ||
.pipe(rename('environment.ts')) | ||
.pipe(gulp.dest('src')); | ||
}) | ||
|
||
gulp.task('configure:production', () => { | ||
return gulp | ||
.src('environments/environment.prod.ts') | ||
.pipe(rename('environment.ts')) | ||
.pipe(gulp.dest('src')); | ||
}) | ||
|
||
gulp.task('compile:dev', () => { | ||
const tsProject = ts.createProject('tsconfig.json'); | ||
|
||
return tsProject | ||
.src() | ||
.pipe(sourcemaps.init()) | ||
.pipe(tsProject()).js | ||
.pipe(sourcemaps.write({ sourceRoot: '/dist' })) | ||
.pipe(gulp.dest('dist')); | ||
}) | ||
|
||
gulp.task('compile:production', () => { | ||
const tsProject = ts.createProject('tsconfig.production.json'); | ||
|
||
return tsProject | ||
.src() | ||
.pipe(tsProject()).js | ||
.pipe(gulp.dest('dist')); | ||
}) | ||
|
||
gulp.task('build:demo', gulp.series(['configure:demo', 'compile:dev'])); | ||
gulp.task('build:prod', gulp.series(['configure:production', 'compile:production'])); | ||
gulp.task('watch:only', () => { | ||
gulp.watch('src/**/*.ts', gulp.series(['compile:dev'])); | ||
}) | ||
gulp.task('watch', gulp.series(['build:demo', 'watch:only'])) |
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,38 @@ | ||
# Gateway Service Specialized Variables | ||
SERVICE_CHANNEL="api-gateway" | ||
DIRECT_MESSAGE_PORT="6555" | ||
|
||
# Ecosystem Defined Variables | ||
HEDERA_NET="testnet" | ||
PREUSED_HEDERA_NET="testnet" | ||
MQ_ADDRESS="localhost" | ||
MRV_ADDRESS="http://localhost:3003/mrv" | ||
MQ_MAX_PAYLOAD="1048576" | ||
#LOG_LEVEL="2" | ||
#MQ_MESSAGE_CHUNK=5000000 | ||
#RAW_REQUEST_LIMIT="1gb" | ||
#JSON_REQUEST_LIMIT="1mb" | ||
|
||
#CACHE | ||
HOST_CACHE='localhost' | ||
PORT_CACHE='6379' | ||
ENABLE_CACHE='true' | ||
USE_SENTINEL='false' | ||
SENTINEL_HOSTS='' | ||
REDIS_MASTER_NAME='' | ||
|
||
#PINO_LOGGER | ||
TRANSPORTS="CONSOLE, MONGO" | ||
DB_LOGGER_NAME="logger_db" | ||
DB_LOGGER_HOST="localhost" | ||
DB_LOGGER_COLLECTION="log" | ||
LOG_FILE_PATH="./logs/app.log" | ||
LOG_LEVEL="info" | ||
SEQ_SERVER_URL="http://localhost:5341" | ||
SEQ_UI_URL="http://localhost:5341" | ||
SEQ_API_KEY="" | ||
|
||
#MONGO_INIT | ||
MIN_POOL_SIZE="1" | ||
MAX_POOL_SIZE="5" | ||
MAX_IDLE_TIME_MS="30000" |
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,38 @@ | ||
# Gateway Service Specialized Variables | ||
SERVICE_CHANNEL="api-gateway" | ||
#DIRECT_MESSAGE_PORT="6555" | ||
|
||
# Ecosystem Defined Variables | ||
HEDERA_NET="testnet" | ||
PREUSED_HEDERA_NET="testnet" | ||
MQ_ADDRESS="localhost" | ||
MRV_ADDRESS="http://localhost:3003/mrv" | ||
MQ_MAX_PAYLOAD="1048576" | ||
#LOG_LEVEL="2" | ||
#MQ_MESSAGE_CHUNK=5000000 | ||
#RAW_REQUEST_LIMIT="1gb" | ||
#JSON_REQUEST_LIMIT="1mb" | ||
|
||
#CACHE | ||
HOST_CACHE='localhost' | ||
PORT_CACHE='6379' | ||
ENABLE_CACHE='true' | ||
USE_SENTINEL='false' | ||
SENTINEL_HOSTS='' | ||
REDIS_MASTER_NAME='' | ||
|
||
#PINO_LOGGER | ||
TRANSPORTS="CONSOLE, MONGO" | ||
DB_LOGGER_NAME="logger_db" | ||
DB_LOGGER_HOST="localhost" | ||
DB_LOGGER_COLLECTION="log" | ||
LOG_FILE_PATH="./logs/app.log" | ||
LOG_LEVEL="info" | ||
SEQ_SERVER_URL="http://localhost:5341" | ||
SEQ_UI_URL="http://localhost:5341" | ||
SEQ_API_KEY="" | ||
|
||
#MONGO_INIT | ||
MIN_POOL_SIZE="1" | ||
MAX_POOL_SIZE="5" | ||
MAX_IDLE_TIME_MS="30000" |
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,38 @@ | ||
# Gateway Service Specialized Variables | ||
SERVICE_CHANNEL="api-gateway" | ||
DIRECT_MESSAGE_PORT="6555" | ||
|
||
# Ecosystem Defined Variables | ||
HEDERA_NET="" | ||
PREUSED_HEDERA_NET="" | ||
MQ_ADDRESS="" | ||
MRV_ADDRESS="" | ||
MQ_MAX_PAYLOAD="" | ||
#LOG_LEVEL="2" | ||
#MQ_MESSAGE_CHUNK=5000000 | ||
#RAW_REQUEST_LIMIT="1gb" | ||
#JSON_REQUEST_LIMIT="1mb" | ||
|
||
#CACHE | ||
HOST_CACHE='' | ||
PORT_CACHE='' | ||
ENABLE_CACHE='true' | ||
USE_SENTINEL='false' | ||
SENTINEL_HOSTS='' | ||
REDIS_MASTER_NAME='' | ||
|
||
#PINO_LOGGER | ||
TRANSPORTS="CONSOLE, MONGO" | ||
DB_LOGGER_NAME="" | ||
DB_LOGGER_HOST="" | ||
DB_LOGGER_COLLECTION="" | ||
LOG_FILE_PATH="" | ||
LOG_LEVEL="" | ||
SEQ_SERVER_URL="" | ||
SEQ_UI_URL="" | ||
SEQ_API_KEY="" | ||
|
||
#MONGO_INIT | ||
MIN_POOL_SIZE="" | ||
MAX_POOL_SIZE="" | ||
MAX_IDLE_TIME_MS="" |
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,3 @@ | ||
export const ApplicationEnvironment = { | ||
demoMode: true | ||
} |
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,3 @@ | ||
export const ApplicationEnvironment = { | ||
demoMode: false | ||
} |
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,6 @@ | ||
{ | ||
"watch": ["./dist", "../interfaces/dist", "../common/dist"], | ||
"delay": 2500, | ||
"ext": "ts, js", | ||
"exec": "node dist/index.js" | ||
} |
Oops, something went wrong.