Skip to content

Release prod #58

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

Open
wants to merge 93 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
ba41d0b
test: add RestClient endpoint tests
Ansonhkg Jun 24, 2024
722b26a
feat: add new `v2` endpoint for `mintNextAndAddAuthMethodsHandler`
Ansonhkg Jun 24, 2024
09ecfce
feat: introduced `VersionStrategy` to run different logic based on th…
Ansonhkg Jun 24, 2024
4e05cfc
feat: add `ThirdWeb` lib
Ansonhkg Jun 24, 2024
032154b
wip: adding a request id source to the response. Did it get processed…
Ansonhkg Jun 25, 2024
f27391e
feat(test): add RestClient tests on minting
Ansonhkg Jun 25, 2024
c48005d
feat(package.json): add bun to devDependencies
Ansonhkg Jun 25, 2024
edd6924
chore: change file name to make it compatible to different OSs
Ansonhkg Jul 10, 2024
6eca4c3
feat: added thirdweb in mintPKP with Round Robin
jatin0814 Jul 21, 2024
55078cd
added logs: fetch PKP
jatin0814 Jul 23, 2024
0a936c7
added gaslimit in mintPKP and update chainId
jatin0814 Jul 23, 2024
4d89640
fix: mintCost type error
jatin0814 Jul 23, 2024
834f869
fix: conflict
jatin0814 Jul 24, 2024
2076663
added paymentDb
jatin0814 Jul 24, 2024
b984bea
wip: datil-test
jatin0814 Jul 24, 2024
d830a04
wip: datil-test
jatin0814 Jul 24, 2024
f059bb1
merge -> HEAD
jatin0814 Jul 25, 2024
fcfdf58
added sockets in delegate api
jatin0814 Jul 26, 2024
52ff925
added sockets in delegate api
jatin0814 Jul 26, 2024
7af53b8
fix: delegate user
jatin0814 Jul 26, 2024
43aee62
remove delete redis data logic for debug
jatin0814 Jul 26, 2024
50e487a
remove delete redis data logic for debug
jatin0814 Jul 26, 2024
4c99291
update rate limit
jatin0814 Jul 26, 2024
4920d8a
feat: get transaction data by queueId
jatin-threely Jul 28, 2024
321d4a6
added logic for minting capacity credit to thirdweb wallets
jatin-threely Aug 4, 2024
78baf0f
added logic for minting capacity credit to thirdweb wallets
jatin-threely Aug 4, 2024
f8c32ec
update thirdweb wallet list
jatin-threely Aug 4, 2024
f75f8a2
add delay in fallback request
jatin-threely Aug 4, 2024
dce347d
update fallback function
jatin-threely Aug 4, 2024
a6b6574
errored stated added
jatin-threely Aug 4, 2024
c0261af
added sentry
jatin-threely Aug 6, 2024
6c1a877
failedTx webhook added
jatin-threely Aug 6, 2024
79e8ab0
upgrade docker
Aug 7, 2024
681a027
feat: sentry
jatin-threely Aug 7, 2024
bd39097
Merge pull request #1 from TriaHQ/upgrade-docker
triasteve Aug 8, 2024
1862c07
add command to start docker
Aug 8, 2024
16677da
Merge pull request #2 from TriaHQ/docker-start
jatin-threely Aug 8, 2024
0b78b9c
release to dev env
Aug 8, 2024
faa0a7e
Merge pull request #3 from TriaHQ/release-dev
jatin-threely Aug 8, 2024
918e2c3
fix: sentry issue
jatin-threely Aug 9, 2024
82d33f0
Merge branch 'feature/lit-3479-relayerthirdweb-proxy-requests-to-thir…
jatin-threely Aug 9, 2024
cef7b74
update failedTx webhook
jatin-threely Aug 10, 2024
0f99823
update failedTx webhook
jatin-threely Aug 10, 2024
da9f3de
update failedTx webhook
jatin-threely Aug 10, 2024
7c8c0e4
update failedTx webhook
jatin-threely Aug 10, 2024
7ab7949
update relayer
jatin-threely Aug 14, 2024
08566a1
update relayer
jatin-threely Aug 14, 2024
d74e5f9
env added in sentry
jatin-threely Aug 15, 2024
b57269d
redis added
jatin-threely Aug 15, 2024
4827ba5
redis added
jatin-threely Aug 15, 2024
85a8576
redis added
jatin-threely Aug 15, 2024
bf6678d
redis added
jatin-threely Aug 15, 2024
0ccf796
making hardcoded redis key
jatin-threely Aug 15, 2024
81bd39d
add env
Aug 22, 2024
d327fc2
removed adding to payment db logic
jatin-threely Aug 30, 2024
604ced1
release-prod
Sep 4, 2024
411e51e
Merge pull request #4 from TriaHQ/release-prod
triasteve Sep 4, 2024
9d3ea74
Merge pull request #5 from TriaHQ/feature/lit-3479-relayerthirdweb-pr…
jatin-threely Sep 4, 2024
2fd0a79
added optimizatio
jatin-threely Sep 4, 2024
705e8c8
Merge branch 'thirdweb-main' of https://github.com/TriaHQ/relay-serve…
jatin-threely Sep 4, 2024
fd54088
added cron to tsconfig
jatin-threely Sep 5, 2024
d9fc759
added logs
jatin-threely Sep 6, 2024
0a29c85
change status code
jatin-threely Sep 6, 2024
dfb1efb
Segregation added
jatin-threely Sep 6, 2024
35d24e2
update rr logic
jatin-threely Sep 7, 2024
a99b944
deploy dev
Sep 8, 2024
78a9b3c
Merge pull request #6 from TriaHQ/deploy-dev
triasteve Sep 8, 2024
5b91093
udpate rr
jatin-threely Sep 9, 2024
cf717a4
udpate gaslimit
jatin-threely Sep 12, 2024
ef74d4e
added manual gasLimit
jatin-threely Sep 12, 2024
52fdc01
added address to set
jatin-threely Sep 12, 2024
349c6e2
added sentry in fetch pkp
jatin-threely Sep 13, 2024
a418ef2
update docker script and gas limit
jatin-threely Sep 22, 2024
46d2690
Upate Makefile
triasteve Sep 24, 2024
de80877
Merge pull request #7 from TriaHQ/thirdweb-dev
jatin-threely Sep 26, 2024
5bfb41f
error handling added thirdweb
jatin-threely Sep 30, 2024
f5f7f22
Merge branch 'feature/lit-3479-relayerthirdweb-proxy-requests-to-thir…
jatin-threely Sep 30, 2024
71e07e3
Update Makefile
triasteve Oct 2, 2024
4033b3d
update RR
jatin-threely Oct 7, 2024
d3251cd
Merge pull request #8 from TriaHQ/feature/lit-3479-relayerthirdweb-pr…
jatin-threely Oct 7, 2024
45498f2
Merge branch 'thirdweb-dev' of https://github.com/TriaHQ/relay-server…
jatin-threely Oct 7, 2024
7fa146e
Merge pull request #9 from TriaHQ/feature/lit-3479-relayerthirdweb-pr…
jatin-threely Oct 7, 2024
df3cf71
Merge pull request #10 from TriaHQ/feature/lit-3479-relayerthirdweb-p…
jatin-threely Oct 7, 2024
1b16b92
Merge pull request #11 from TriaHQ/thirdweb-dev
jatin-threely Oct 8, 2024
a633d31
update start command
jatin-threely Oct 10, 2024
bde0548
Merge pull request #12 from TriaHQ/thirdweb-dev
jatin-threely Oct 10, 2024
925e451
Adding document for TEST env
triasteve Oct 11, 2024
0121b48
Update Makefile
triasteve Oct 11, 2024
18c8d5c
Update Makefile
triasteve Oct 11, 2024
879e131
Merge pull request #13 from TriaHQ/thirdweb-preprod
jatin-threely Oct 11, 2024
1c05d6f
Merge pull request #14 from TriaHQ/thirdweb-main
jatin-threely Oct 29, 2024
3600af1
Adding deploy-preprod workflow
triasteve Nov 9, 2024
c98d7f5
fix release prod
Nov 17, 2024
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Makefile
48 changes: 48 additions & 0 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker Build

on:
push:
branches:
- thirdweb-dev

jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout the code from the repository
- name: Checkout code
uses: actions/checkout@v3

# Set up Docker (if it's not already set up)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Set up AWS credentials
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
aws-region: ${{ secrets.AWS_REGION_DEV }}

# Install necessary dependencies if needed (like gcc, make, etc.)
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential

- name: Authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc

- name: Authenticate with sentry
run: echo "[auth]\ntoken=${{ secrets.SENTRY_TOKEN }}" > .sentryclirc

- name: Build Docker Image
run: make build

- name: Push Docker Image
run: make release

- name: Deploy K8S
run: |
aws eks update-kubeconfig --region ap-south-1 --name tf-tria-dev
make deploy-k8s-dev
48 changes: 48 additions & 0 deletions .github/workflows/deploy-preprod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker Build

on:
push:
branches:
- thirdweb-preprod

jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout the code from the repository
- name: Checkout code
uses: actions/checkout@v3

# Set up Docker (if it's not already set up)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Set up AWS credentials
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_PREPROD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PREPROD }}
aws-region: ${{ secrets.AWS_REGION_PREPROD }}

# Install necessary dependencies if needed (like gcc, make, etc.)
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential

- name: Authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc

- name: Authenticate with sentry
run: echo "[auth]\ntoken=${{ secrets.SENTRY_TOKEN }}" > .sentryclirc

- name: Build Docker Image
run: make build

- name: Push Docker Image
run: make release-preprod

- name: Deploy K8S
run: |
aws eks update-kubeconfig --region us-east-1 --name tf-tria-preprod
make deploy-k8s-preprod
48 changes: 48 additions & 0 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker Build

on:
push:
branches:
- thirdweb-main

jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout the code from the repository
- name: Checkout code
uses: actions/checkout@v3

# Set up Docker (if it's not already set up)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Set up AWS credentials
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }}
aws-region: ${{ secrets.AWS_REGION_PROD }}

# Install necessary dependencies if needed (like gcc, make, etc.)
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential

- name: Authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc

- name: Authenticate with sentry
run: echo "[auth]\ntoken=${{ secrets.SENTRY_TOKEN }}" > .sentryclirc

- name: Build Docker Image
run: make build

- name: Push Docker Image
run: make release-prod

- name: Deploy K8S
run: |
aws eks update-kubeconfig --region us-east-1 --name tf-tria-prod
make deploy-k8s-prod
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ node_modules
.env*
dist
.DS_Store
*.pem
*.pem
.sentryclirc
.npmrc

cron
7 changes: 7 additions & 0 deletions .gitignore copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.env*
dist
.DS_Store
*.pem
.npmrc
.sentryclirc
44 changes: 22 additions & 22 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#65c89b",
"activityBar.background": "#65c89b",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#945bc4",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#15202b99",
"sash.hoverBorder": "#65c89b",
"statusBar.background": "#42b883",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#359268",
"statusBarItem.remoteBackground": "#42b883",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#42b883",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#42b88399",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#42b883"
}
// {
// "workbench.colorCustomizations": {
// "activityBar.activeBackground": "#65c89b",
// "activityBar.background": "#65c89b",
// "activityBar.foreground": "#15202b",
// "activityBar.inactiveForeground": "#15202b99",
// "activityBarBadge.background": "#945bc4",
// "activityBarBadge.foreground": "#e7e7e7",
// "commandCenter.border": "#15202b99",
// "sash.hoverBorder": "#65c89b",
// "statusBar.background": "#42b883",
// "statusBar.foreground": "#15202b",
// "statusBarItem.hoverBackground": "#359268",
// "statusBarItem.remoteBackground": "#42b883",
// "statusBarItem.remoteForeground": "#15202b",
// "titleBar.activeBackground": "#42b883",
// "titleBar.activeForeground": "#15202b",
// "titleBar.inactiveBackground": "#42b88399",
// "titleBar.inactiveForeground": "#15202b99"
// },
// "peacock.color": "#42b883"
// }
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:16.7-alpine3.14 as builder

WORKDIR /app

COPY . .

RUN yarn global add @sentry/cli pm2
RUN env NODE_ENV=development yarn install
RUN env NODE_ENV=production yarn build

CMD ["ash", "start.sh"]
65 changes: 65 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
service := relay-server

# Default environment is dev
env := dev

# Define account_id based on environment
account_id := $(if $(filter $(env),prod),060795900752, \
$(if $(filter $(env),preprod),060795900752, \
$(if $(filter $(env),test),535002881389, \
008971671473)))
tag := $(if $(filter $(env),preprod),preprod,latest)


# Define variables based on environment
region := $(if $(filter $(env),dev),ap-south-1,us-east-1)
namespace := $(if $(filter $(env),prod),tria-prod,$(if $(filter $(env),preprod),tria-preprod,tria-dev))

# Docker settings
OSFLAG := env DOCKER_DEFAULT_PLATFORM=linux/amd64 OSFLAG=linux/amd64

build:
$(OSFLAG) docker build -t ${service}:${tag} .

release:
aws --region ${region} ecr get-login-password | docker login -u AWS --password-stdin ${account_id}.dkr.ecr.${region}.amazonaws.com
$(OSFLAG) docker tag ${service}:${tag} ${account_id}.dkr.ecr.${region}.amazonaws.com/${service}:${tag}
$(OSFLAG) docker push ${account_id}.dkr.ecr.${region}.amazonaws.com/${service}:${tag}

for digest in $$(aws ecr describe-images --repository-name ${service} --filter tagStatus=UNTAGGED --query 'imageDetails[*].imageDigest' --output text --region ${region}); \
do \
aws ecr batch-delete-image --repository-name ${service} --image-ids imageDigest=$${digest} --region ${region}; \
done

deploy-k8s:
kubectl rollout restart deployment/${service} -n ${namespace}

release-dev:
$(MAKE) release env=dev

release-test:
$(MAKE) release env=test

release-preprod:
$(MAKE) build env=preprod
$(MAKE) release env=preprod

release-prod:
$(MAKE) release env=prod

deploy-k8s-dev:
$(MAKE) deploy-k8s env=dev

deploy-k8s-test:
$(MAKE) deploy-k8s env=test

deploy-k8s-preprod:
$(MAKE) deploy-k8s env=preprod

deploy-k8s-prod:
$(MAKE) deploy-k8s env=prod

reset:
$(OSFLAG) docker rm -f $$($(OSFLAG) docker ps -a -q)
$(OSFLAG) docker system prune -f

8 changes: 8 additions & 0 deletions config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const {
NETWORK,
USE_SOLO_NET,
EXPECTED_ORIGINS,
RELAYER_BASE_URL,
PAYER_SECRET,
API_KEY,
NODE_ENV
} = process.env;

const baseConfig = {
Expand Down Expand Up @@ -54,6 +58,10 @@ const baseConfig = {
network: NETWORK || "cayenne",
useSoloNet: USE_SOLO_NET === "true",
expectedOrigins: EXPECTED_ORIGINS?.split(",") || ["http://localhost:3000"],
baseUrl: RELAYER_BASE_URL,
apiKey: API_KEY,
payerSecret: PAYER_SECRET,
env: NODE_ENV
};

export default {
Expand Down
36 changes: 36 additions & 0 deletions dev-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Deploy Relay Server

This document show an end to end pipeline on how we can build, release & deploy an `relay-server` into AWS Dev env

## Prerequisite
- Install [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
- Install [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/)
- Run `xcode-select --install` to install latest command line tools in your MacOS
- Install [Docker Desktop](https://docs.docker.com/desktop/install/mac-install/). After installation, you should set resources limit to `8 CPU` & `12GB` memory
- You should be granted `Administrator` access into [tria-dev aws account](https://d-9067e355bc.awsapps.com/start/#/?tab=accounts). If not, ask Steven or Avi

## Setup
- Open a new shell console terminal, cd to this `current directoty` & paste your AWS credentials. Then, run below command
```
# build sample service docker image
make build

# push docker image into AWS dev ecr
make release

# deploy sample service into DEV env
make deploy-k8s-dev
```

```
# TEST env
# build sample service docker image
make build

# push docker image into AWS dev ecr
make release-test

# deploy sample service into DEV env
make deploy-k8s-test
```

24 changes: 24 additions & 0 deletions eventEmitter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// eventEmitter.js
import EventEmitter from 'events';

export const eventEmitter = new EventEmitter();


// waitForEvent.js
export const waitForEvent = (emitter: EventEmitter, eventName: string, timeout: number, queueId: string) => {
return new Promise((resolve, reject) => {
const timer = setTimeout(() => {
emitter.removeListener(eventName, onEvent);
reject(new Error(`Timeout: Did not receive ${eventName} within ${timeout}ms`));
}, timeout);

const onEvent = (data: any) => {
clearTimeout(timer);
if (data.queueId === queueId) {
resolve(data);
}
};

emitter.once(eventName, onEvent);
});
};
2 changes: 1 addition & 1 deletion fido-conformance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fetch("https://mds3.certinfra.fidoalliance.org/getEndpoints", {
headers: { "Content-Type": "application/json" },
})
.then((resp) => resp.json())
.then((json) => {
.then((json:any) => {
const mdsServers: string[] = json.result;

return MetadataService.initialize({
Expand Down
Loading