Skip to content

Commit

Permalink
UPDATED
Browse files Browse the repository at this point in the history
  • Loading branch information
Amarjha01 committed Sep 1, 2024
1 parent 756b2e7 commit faa4257
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/deploy-backend.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/common/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// const backendDomain = 'http://localhost:5000';
const backendDomain = 'api.electramart.ninja';
const backendDomain = 'https://api.electramart.ninja';


const summaryApi = {
Expand Down

0 comments on commit faa4257

Please sign in to comment.