Skip to content

Commit

Permalink
Merge pull request #27 from ferrumnet/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
zikriya authored Mar 28, 2023
2 parents 7bd4d62 + 697a3b6 commit cec3678
Show file tree
Hide file tree
Showing 21 changed files with 1,692 additions and 51 deletions.
7 changes: 5 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
PORT=3000
MONGODB_URL=mongodb://127.0.0.1:27017/multiswap-node
QUEUE=Transaction
GATEWAY_BACKEND_URL=
GATEWAY_BACKEND_URL=https://api-leaderboard.dev.svcs.ferrumnetwork.io
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
PRIVATE_KEY=
PUBLIC_KEY=
69 changes: 69 additions & 0 deletions .github/workflows/deploy_dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Deploy to Amazon ECS

on:
push:
branches:
- develop

env:
AWS_REGION: us-east-2 # set this to your preferred AWS region, e.g. us-west-1
ECR_REPOSITORY: ferrum-dev-multiswap # set this to your Amazon ECR repository name
ECS_SERVICE: multiswap-node # set this to your Amazon ECS service name
ECS_CLUSTER: ferrum-dev-cluster # set this to your Amazon ECS cluster name
ECS_TASK_DEFINITION: multiswap-node # set this to the path to your Amazon ECS task definition
# file, e.g. .aws/task-definition.json
CONTAINER_NAME: multiswap-node # set this to the name of the container in the
# containerDefinitions section of your task definition

permissions:
contents: read

jobs:
build:
name: Build
runs-on: ubuntu-latest
environment: development

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
deploy:
needs: build
name: Deploy
runs-on: ubuntu-latest
environment: development
steps:
- name: Deploy to ecs
id: deploy-image
env:
IMAGE_TAG: ${{ github.sha }}
run: |
docker run fabfuel/ecs-deploy:1.10.2 ecs deploy ${{ env.ECS_CLUSTER }} ${{ env.ECS_SERVICE }} --tag ${{ github.sha }} --region ${{ env.AWS_REGION }} --access-key-id ${{ secrets.AWS_ACCESS_KEY_ID }} --secret-access-key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ yarn-error.log
!.env*.example

# Code coverage
coverage
coverage

# package lock
package-lock.json
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18.12.1-alpine

WORKDIR /app

COPY . /app

RUN mv .env.example .env
RUN yarn install

EXPOSE 3000

CMD yarn dev
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Redis Version `v7.0.8`

Run the Redis Server in your machine by using `redis-server` command

Run this command `cp .env.example .env` to create .env file

Run `yarn` OR `yarn install` at the root of the repo

Run `yarn dev` to run Server
19 changes: 19 additions & 0 deletions devops/logs-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Install AWS CLI

https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions

# Configure SSO session

Use following document to configure your aws credentials via AWS SSO
https://docs.aws.amazon.com/cli/latest/userguide/sso-configure-profile-token.html


# View AWS service logs
aws logs tail --follow --region us-east-2 <log_group_name> --since <time>

example:
for past 5 minutes logs

aws logs tail --follow --region us-east-2 /ferrum/ecs/multiswap-node --since 5m


48 changes: 48 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: '3.8'
# networks:
# app-network:
# driver: bridge

services:
redis:
container_name: redis
image: 'redis:7.0.8'
ports:
- '6379:6379'
command: redis-server --save 20 1 --loglevel warning
volumes:
- redis:/data
restart:
on-failure
# networks:
# - multiswap
expose:
- 6379
multiswap_app:
build:
context: ./
# target: development
container_name: multiswap_app
image: multiswap_app:latest
depends_on:
- redis
ports:
- 3000:3000
environment:
REDIS_HOST: redis
REDIS_PORT: 6379

links:
- redis
restart:
on-failure
# networks:
# - multiswap

# networks:
# multiswap:
# external:
# name: app
volumes:
redis:
driver: local
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@
},
"dependencies": {
"axios": "^1.2.6",
"big.js": "^6.2.1",
"bullmq": "^3.5.11",
"crypto-js": "^4.1.1",
"dotenv": "^16.0.3",
"ethereumjs-util": "^7.1.5",
"express": "^4.17.2",
"web3": "^1.8.1"
"web3": "^1.8.1",
"web3-utils": "^1.9.0"
}
}
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ app.use(express.json());
app.use(express.urlencoded({ extended: true }));

// v1 api routes
app.use('/', routes);
app.use('/api', routes);

// send back a 404 error for any unknown api request
app.use((req: Request, res: Response, next: NextFunction) => {
Expand Down
Loading

0 comments on commit cec3678

Please sign in to comment.