diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 08e6dd5..ad881e6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -4,6 +4,12 @@ on: workflow_dispatch: pull_request: branches: [main] +env: + AWS_REGION: ap-south-1 + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + PRIVATE_SSH_KEY: ${{ secrets.AWS_SSH_KEY }} + SERVER_PUBLIC_IP: ${{ secrets.AWS_PUBLIC_KEY }} jobs: deploy: @@ -35,7 +41,6 @@ jobs: id: login-ecr uses: aws-actions/amazon-ecr-login@v1 - - name: Build, tag, and push image to Amazon ECR env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} @@ -44,5 +49,26 @@ jobs: run: | docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + - name: Deploy docker image to EC2 + env: + REGISTRY: ${{ steps.login-ecr.outputs.registry }} + REPOSITORY: verses + IMAGE_TAG: latest + AWS_DEFAULT_REGION: ap-south-1 + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.AWS_PUBLIC_KEY}} + username: ubuntu + key: ${{ secrets.AWS_SSH_KEY }} + envs: PRIVATE_SSH_KEY,REGISTRY,REPOSITORY,IMAGE_TAG,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_DEFAULT_REGION,AWS_REGION + script: |- + sudo apt update + sudo apt install docker.io -y + sudo apt install awscli -y + sudo $(aws ecr get-login --no-include-email --region ap-south-1); + sudo docker stop deploy || true + sudo docker rm deploy || true + sudo docker pull $REGISTRY/$REPOSITORY:$IMAGE_TAG + sudo docker run -d -e PORT=80 -e JWT_SECRET=fbd88e -e GOLD_KEY=nfjd878 -e DB_CONN=dgddbujdb --name deploy -p 80:80 $REGISTRY/$REPOSITORY:$IMAGE_TAG + - \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d86d452..01284e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,4 +6,7 @@ ADD Verses /usr/bin/Verses EXPOSE 80 +CMD ["Verses"] + + CMD ["Verses"] \ No newline at end of file diff --git a/README.md b/README.md index fef84b4..7dca5aa 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,16 @@ A social media Backend APi ## API DOCUMENTATION +### +Welcome Page +``` +http://13.201.15.193/app +``` + ### Base URL +``` +http://13.201.15.193/api +``` ### Endpoints @@ -179,14 +188,7 @@ A social media Backend APi Status Code: 204 No Content - #### Administrative Tasks - - #### Gold Webhooks `POST` `/gold/webhooks` - Description: Receive webhook notifications related to gold. - - Request Body: - Response: - - Status Code: 200 OK - #### Metrics `GET` `/metrics` Description: Retrieve server metrics.