From faa425749d021f0b294fdfc06eacb81832d867ad Mon Sep 17 00:00:00 2001 From: Amar Date: Sun, 1 Sep 2024 18:46:05 +0530 Subject: [PATCH] UPDATED --- .github/workflows/deploy-backend.yml | 61 ++++++++++++++++++++++++++++ backend/index.js | 2 +- frontend/src/common/index.jsx | 2 +- 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/deploy-backend.yml diff --git a/.github/workflows/deploy-backend.yml b/.github/workflows/deploy-backend.yml new file mode 100644 index 0000000..4bd1d27 --- /dev/null +++ b/.github/workflows/deploy-backend.yml @@ -0,0 +1,61 @@ +name: Deploy Backend to Docker Hub and Elastic Beanstalk + +on: + push: + branches: + - main + - backend + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.11.1' + + - name: Build Docker image + run: | + docker build -t my-backend-app -f Dockerfile . + + - name: Log in to Docker Hub + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + run: | + echo "$DOCKER_HUB_ACCESS_TOKEN" | docker login --username "$DOCKER_HUB_USERNAME" --password-stdin + + - name: Tag Docker image + run: | + docker tag my-backend-app:latest amarjha01/electramart:latest + + - name: Push Docker image to Docker Hub + run: | + docker push amarjha01/electramart:latest + + # - name: Install AWS Elastic Beanstalk CLI + # run: | + # sudo pip install awsebcli + + # - name: Prepare source bundle for Elastic Beanstalk + # run: | + # mkdir -p eb-deploy + # cp Dockerrun.aws.json eb-deploy/ + # cp -r backend/* eb-deploy/ + # cd eb-deploy + # zip -r ../app.zip . + + # - name: Deploy to Elastic Beanstalk + # env: + # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # AWS_REGION: ap-south-1 + # run: | + # eb init -p docker my-backend-app --region $AWS_REGION + # eb use My-backend-app-env2 + # eb deploy diff --git a/backend/index.js b/backend/index.js index 9ae181f..bb63b7d 100644 --- a/backend/index.js +++ b/backend/index.js @@ -13,7 +13,7 @@ const allowedOrigins = [ // process.env.FRONTEND_URL, // process.env.FRONTEND_URL2, // 'http://localhost:5173', - 'api.electramart.ninja' + 'https://api.electramart.ninja' ]; app.use(cors({ diff --git a/frontend/src/common/index.jsx b/frontend/src/common/index.jsx index 5175d95..c7f858f 100644 --- a/frontend/src/common/index.jsx +++ b/frontend/src/common/index.jsx @@ -1,5 +1,5 @@ // const backendDomain = 'http://localhost:5000'; -const backendDomain = 'api.electramart.ninja'; +const backendDomain = 'https://api.electramart.ninja'; const summaryApi = {