Skip to content

Commit

Permalink
Merge branch 'temp-develop' into implement/didAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
varsha766 authored Sep 18, 2024
2 parents d57b3f6 + 6e856a6 commit 0e5f48b
Show file tree
Hide file tree
Showing 26 changed files with 1,081 additions and 141 deletions.
11 changes: 11 additions & 0 deletions .deploy/SSL2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# secret.yaml
apiVersion: v1
kind: Secret

metadata:
name: entity-ssl-test
namespace: hypermine-development
type: kubernetes.io/tls
stringData:
tls.key: ""
tls.crt: ""
13 changes: 13 additions & 0 deletions .deploy/cert2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: entity-ssl-test
namespace: hypermine-development
spec:
dnsNames:
- api.entity-test.hypersign.id
- "*.api.entity-test.hypersign.id"
issuerRef:
kind: Issuer
name: letsencrypt-production
secretName: entity-ssl-test
107 changes: 61 additions & 46 deletions .deploy/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -16,50 +15,63 @@ spec:
app: entity-api
spec:
containers:
- name: entity-api
image: __GOOGLE_ARTIFACT_URL__/__GOOGLE_PROJECT_ID__/__GOOGLE_ARTIFACT_REPO__/enity-api-service:__LATEST_RELEASE_TAG__
imagePullPolicy: Always
- name: entity-api
image: __GOOGLE_ARTIFACT_URL__/__GOOGLE_PROJECT_ID__/__GOOGLE_ARTIFACT_REPO__/enity-api-service:__LATEST_RELEASE_TAG__
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /api/v1/edv/state
port: 3001
initialDelaySeconds: 120
periodSeconds: 30
failureThreshold: 3

resources:
limits:
memory: "1Gi"
cpu: "1000m"
ports:
- containerPort: __PORT__
env:
- name: PORT
value: "__PORT__"
- name: BASE_DB_PATH
value: __BASE_DB_PATH__
- name: DB_CONFIG
value: __DB_CONFIG__
- name: HID_NETWORK_RPC
value: __HID_NETWORK_RPC__
- name: HID_NETWORK_API
value: __HID_NETWORK_API__
- name: HID_NETWORK_NAMESPACE
value: __HID_NETWORK_NAMESPACE__
- name: EDV_BASE_URL
value: __EDV_BASE_URL__
- name: EDV_CONFIG_DIR
value: __EDV_CONFIG_DIR__
- name: EDV_DID_FILE_PATH
value: __EDV_DID_FILE_PATH__
- name: EDV_KEY_FILE_PATH
value: __EDV_KEY_FILE_PATH__
- name: MNEMONIC
value: __MNEMONIC__
- name: JWT_SECRET
value: __JWT_SECRET__
- name: WHITELISTED_CORS
value: "['https://entity.hypersign.id','https://api.entity.hypersign.id','https://wallet-prajna.hypersign.id']"
volumeMounts:
- name: mongo
mountPath: "/data"
volumes:
resources:
limits:
memory: "2Gi"
cpu: "1000m"
ports:
- containerPort: __PORT__
env:
- name: PORT
value: "__PORT__"
- name: BASE_DB_PATH
value: __BASE_DB_PATH__
- name: DB_CONFIG
value: __DB_CONFIG__
- name: HID_NETWORK_RPC
value: __HID_NETWORK_RPC__
- name: HID_NETWORK_API
value: __HID_NETWORK_API__
- name: HID_NETWORK_NAMESPACE
value: __HID_NETWORK_NAMESPACE__
- name: EDV_BASE_URL
value: __EDV_BASE_URL__
- name: EDV_CONFIG_DIR
value: __EDV_CONFIG_DIR__
- name: EDV_DID_FILE_PATH
value: __EDV_DID_FILE_PATH__
- name: EDV_KEY_FILE_PATH
value: __EDV_KEY_FILE_PATH__
- name: MNEMONIC
value: __MNEMONIC__
- name: JWT_SECRET
value: __JWT_SECRET__
- name: GLOBAL_TXN_CONTROLLER_QUEUE
value: __GLOBAL_TXN_CONTROLLER_QUEUE__
- name: RABBIT_MQ_URI
value: __RABBIT_MQ_URI__
- name: VAULT_PREFIX
value: __VAULT_PREFIX__
- name: WHITELISTED_CORS
value: "['https://entity.hypersign.id','https://api.entity.hypersign.id','https://api.entity-test.hypersign.id','https://wallet-prajna.hypersign.id']"
volumeMounts:
- name: mongo
secret:
secretName: mongo
mountPath: "/data"
volumes:
- name: mongo
secret:
secretName: mongo
---
apiVersion: v1
kind: Service
Expand All @@ -74,9 +86,9 @@ spec:
selector:
app: entity-api
ports:
- port: __PORT__
targetPort: __PORT__
protocol: TCP
- port: __PORT__
targetPort: __PORT__
protocol: TCP
# ---
# apiVersion: apps/v1
# kind: Deployment
Expand Down Expand Up @@ -122,3 +134,6 @@ spec:
# - port: 8080
# targetPort: 8080
# protocol: TCP



25 changes: 25 additions & 0 deletions .deploy/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: entity-api
namespace: hypermine-development
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: entity-api
minReplicas: 1
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 70
70 changes: 70 additions & 0 deletions .deploy/ingress2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: entity-ingress-test
namespace: hypermine-development
annotations:
kubernetes.io/ingress.allow-http: "false"
kubernetes.io/force-ssl-redirect: redirect
ingressClassName: "gce"
kubernetes.io/ingress.global-static-ip-name: entity-ip-test
cert-manager.io/issuer: letsencrypt-production
labels:
name: ingress

spec:
tls:
- secretName: entity-ssl-test
hosts:
- "api.entity-test.hypersign.id"
- "*.api.entity-test.hypersign.id"

rules:
- host: "api.entity-test.hypersign.id"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
- path: /ssi/
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
- path: /api/
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
- host: "*.api.entity-test.hypersign.id"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
- path: /ssi/
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
- path: /api/
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
38 changes: 22 additions & 16 deletions .github/workflows/CI-CD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,36 +82,42 @@ jobs:
- name: "Configure kubectl"
run: gcloud container clusters get-credentials hypermine-gke --region=asia-south1
- name: Replace tags
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__LATEST_RELEASE_TAG__#${{ env.LATEST_RELEASE_TAG }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__LATEST_RELEASE_TAG__#${{ env.LATEST_RELEASE_TAG }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__PORT__/${{ secrets.PORT }}/g'' {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i ''s/__PORT__/${{ secrets.PORT }}/g'' {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__BASE_DB_PATH__#${{ secrets.BASE_DB_PATH }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__BASE_DB_PATH__#${{ secrets.BASE_DB_PATH }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__DB_CONFIG__#${{ secrets.DB_CONFIG }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__DB_CONFIG__#${{ secrets.DB_CONFIG }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__HID_NETWORK_RPC__#${{ secrets.HID_NETWORK_RPC }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__HID_NETWORK_RPC__#${{ secrets.HID_NETWORK_RPC }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__HID_NETWORK_API__#${{ secrets.HID_NETWORK_API }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__HID_NETWORK_API__#${{ secrets.HID_NETWORK_API }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__HID_NETWORK_NAMESPACE__#${{ secrets.HID_NETWORK_NAMESPACE }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__HID_NETWORK_NAMESPACE__#${{ secrets.HID_NETWORK_NAMESPACE }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__EDV_BASE_URL__#${{ secrets.EDV_BASE_URL }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__EDV_BASE_URL__#${{ secrets.EDV_BASE_URL }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__EDV_CONFIG_DIR__#${{ secrets.EDV_CONFIG_DIR }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__EDV_CONFIG_DIR__#${{ secrets.EDV_CONFIG_DIR }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__EDV_DID_FILE_PATH__#${{ secrets.EDV_DID_FILE_PATH }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__EDV_DID_FILE_PATH__#${{ secrets.EDV_DID_FILE_PATH }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__EDV_KEY_FILE_PATH__#${{ secrets.EDV_KEY_FILE_PATH }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__EDV_KEY_FILE_PATH__#${{ secrets.EDV_KEY_FILE_PATH }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__MNEMONIC__#${{ secrets.MNEMONIC }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__GLOBAL_TXN_CONTROLLER_QUEUE__#${{ secrets.GLOBAL_TXN_CONTROLLER_QUEUE }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__JWT_SECRET__#${{ secrets.JWT_SECRET }}#" {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__RABBIT_MQ_URI__#${{ secrets.RABBIT_MQ_URI }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__GOOGLE_ARTIFACT_URL__/${{ secrets.GOOGLE_ARTIFACT_URL }}/g'' {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__VAULT_PREFIX__#${{ secrets.VAULT_PREFIX }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__GOOGLE_ARTIFACT_REPO__/${{ secrets.GOOGLE_ARTIFACT_REPO }}/g'' {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__MNEMONIC__#${{ secrets.MNEMONIC }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__GOOGLE_PROJECT_ID__/${{ secrets.GOOGLE_PROJECT_ID }}/g'' {} \;
run: find .deploy/deployment2.yaml -type f -exec sed -i -e "s#__JWT_SECRET__#${{ secrets.JWT_SECRET }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment2.yaml -type f -exec sed -i ''s/__GOOGLE_ARTIFACT_URL__/${{ secrets.GOOGLE_ARTIFACT_URL }}/g'' {} \;
- name: "Replace secrets"
run: find .deploy/deployment2.yaml -type f -exec sed -i ''s/__GOOGLE_ARTIFACT_REPO__/${{ secrets.GOOGLE_ARTIFACT_REPO }}/g'' {} \;
- name: "Replace secrets"
run: find .deploy/deployment2.yaml -type f -exec sed -i ''s/__GOOGLE_PROJECT_ID__/${{ secrets.GOOGLE_PROJECT_ID }}/g'' {} \;
- name: "Deploy to GKE"
run: kubectl apply -f .deploy/deployment.yaml
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
FROM node:16
FROM node:18
RUN npm install -g npm@latest
WORKDIR /usr/src/app
COPY ./package.json .
RUN npx patch-package -y

COPY ./tsconfig.json .

ENV NODE_OPTIONS="--openssl-legacy-provider --max-old-space-size=4096"

RUN npm install
COPY . .
RUN npm run build
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,22 @@
"@nestjs/passport": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"@nestjs/swagger": "^6.1.4",
"amqp-connection-manager": "^4.1.14",
"amqplib": "^0.10.4",
"argon2": "^0.30.3",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"express-session": "^1.17.3",
"fs": "^0.0.1-security",
"hid-hd-wallet": "git+https://github.com/hypersign-protocol/hid-hd-wallet.git#main",
"hs-ssi-sdk": "github:hypersign-protocol/hid-ssi-js-sdk#testcase/bjj",
"hypersign-edv-client": "github:hypersign-protocol/hypersign-edv-client#develop",
"hypersign-edv-client": "github:hypersign-protocol/hypersign-edv-client#deleteByDocumentId",
"idb-keyval": "^6.2.1",
"mongoose": "^6.8.3",
"passport": "^0.6.0",
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"patch-package": "^8.0.0",
"readline-sync": "^1.4.10",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0",
Expand Down
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DidModule } from './did/did.module';
import { SchemaModule } from './schema/schema.module';
import { CredentialModule } from './credential/credential.module';
import { PresentationModule } from './presentation/presentation.module';
import { TxSendModuleModule } from './tx-send-module/tx-send-module.module';
@Module({
imports: [
ConfigModule.forRoot({
Expand All @@ -18,6 +19,7 @@ import { PresentationModule } from './presentation/presentation.module';
SchemaModule,
CredentialModule,
PresentationModule,
TxSendModuleModule,
],
controllers: [],
providers: [{ provide: APP_FILTER, useClass: AllExceptionsFilter }],
Expand Down
3 changes: 2 additions & 1 deletion src/credential/credential.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import { WhitelistSSICorsMiddleware } from 'src/utils/middleware/cors.middleware
import { TrimMiddleware } from 'src/utils/middleware/trim.middleware';
import { credentialProviders } from './providers/credential.provider';
import { databaseProviders } from '../mongoose/tenant-mongoose-connections';
import { TxSendModuleModule } from 'src/tx-send-module/tx-send-module.module';

@Module({
imports: [EdvModule, HidWalletModule, DidModule],
imports: [EdvModule, HidWalletModule, DidModule, TxSendModuleModule],
controllers: [CredentialController],
providers: [
CredentialService,
Expand Down
Loading

0 comments on commit 0e5f48b

Please sign in to comment.