Skip to content

Commit

Permalink
Merge pull request #16 from ddayto21/backend/configure-load-balancer-ecs
Browse files Browse the repository at this point in the history
feat(ci): auto deploy backend service to aws ecs with load balancer
  • Loading branch information
ddayto21 authored Feb 3, 2025
2 parents 4a74949 + 39277c0 commit b987434
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest

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

- name: Install AWS CLI
Expand Down Expand Up @@ -52,5 +52,5 @@ jobs:
- name: Push Docker image
run: docker push 312093527157.dkr.ecr.us-east-2.amazonaws.com/book-search-backend-service:latest

- name: Update ECS Service
run: aws ecs update-service --cluster ecs-cluster-book-search --service ecs-service-book-search --force-new-deployment --region us-east-2
- name: Update the ECS Service
run: aws ecs update-service --cluster ecs-cluster-fast-api--cluster --service rest-api-load-balancer-service --force-new-deployment --region us-east-2
2 changes: 2 additions & 0 deletions .github/workflows/deploy-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
pull_request:
branches:
- main
paths:
- "frontend/**"

jobs:
deploy:
Expand Down
7 changes: 2 additions & 5 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@
from app.clients.llm_client import LLMClient
from dotenv import load_dotenv

# Load environment variables from .env

load_dotenv()

# Create a FastAPI application instance
app = FastAPI(redirect_slashes=False)

# Configure CORS middleware to allow the frontend (Amplify & localhost) to call this API
app.add_middleware(
CORSMiddleware,
allow_origins=[
"https://main.d2hvd5sv2imel0.amplifyapp.com",
"http://localhost:3000",
],
allow_credentials=True,
allow_methods=["GET", "POST"],
Expand All @@ -44,7 +41,7 @@ def setex(self, key, ttl, value):

return DummyRedis()

# Create a Redis client (or a dummy client if unavailable)

redis_client = get_redis_client()


Expand Down
2 changes: 1 addition & 1 deletion frontend/src/services/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SearchRequest, SearchResponse } from "../../types/api";

const BASE_URL = "http://18.219.50.112:8000"
const BASE_URL = "http://ecs-load-balancer-fast-api-new-1744878951.us-east-2.elb.amazonaws.com"

export async function searchBooks(query: string): Promise<SearchResponse> {
console.log(`Searching for books with query: ${query}`);
Expand Down

0 comments on commit b987434

Please sign in to comment.