diff --git a/.env.example b/.env.example index 2c431d5..1ee9031 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,7 @@ PORT=3000 -MONGODB_URL=mongodb://127.0.0.1:27017/multiswap-node QUEUE=Transaction -GATEWAY_BACKEND_URL= \ No newline at end of file +GATEWAY_BACKEND_URL=https://api-leaderboard.dev.svcs.ferrumnetwork.io +REDIS_HOST=127.0.0.1 +REDIS_PORT=6379 +PRIVATE_KEY= +PUBLIC_KEY= \ No newline at end of file diff --git a/.github/workflows/deploy_dev.yaml b/.github/workflows/deploy_dev.yaml new file mode 100644 index 0000000..12683d0 --- /dev/null +++ b/.github/workflows/deploy_dev.yaml @@ -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 }} + diff --git a/.gitignore b/.gitignore index 297d2d8..499cf08 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,7 @@ yarn-error.log !.env*.example # Code coverage -coverage \ No newline at end of file +coverage + +# package lock +package-lock.json \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8eeb305 --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index ed70598..ab75d88 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/devops/logs-readme.md b/devops/logs-readme.md new file mode 100644 index 0000000..27370c2 --- /dev/null +++ b/devops/logs-readme.md @@ -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 --since