From 1bee0ed9d7e94478206ff0885a7181f6aa304d24 Mon Sep 17 00:00:00 2001 From: Abel Ratanaphan Date: Thu, 22 Aug 2024 17:34:49 -0400 Subject: [PATCH] feat: add wait for service to run --- .github/workflows/aws.yml | 7 +++++++ Dockerfile | 5 +++-- client/src/features/homepage/HomePage.tsx | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml index b061222..29f0e39 100644 --- a/.github/workflows/aws.yml +++ b/.github/workflows/aws.yml @@ -50,6 +50,7 @@ jobs: # Enable error handling set -e set -o pipefail + # Use Docker Buildx to build the image for x86_64 docker buildx build --platform linux/amd64 --push -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT @@ -59,5 +60,11 @@ jobs: # Enable error handling set -e set -o pipefail + # Update the ECS service aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --force-new-deployment + + # Wait until the service has stabilized (new tasks running, old tasks stopped) + aws ecs wait services-stable --cluster ${{ env.ECS_CLUSTER }} --services ${{ env.ECS_SERVICE }} + + echo "Deployment successful and service is stable." diff --git a/Dockerfile b/Dockerfile index 43730a0..9b38891 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,13 +7,14 @@ WORKDIR /usr/src/app COPY package*.json ./ # Install dependencies -RUN npm install -g npm@latest && npm install +RUN npm install -g npm@latest +RUN npm install # Copy the rest of the application code COPY ./client ./client COPY ./server ./server -# Build the client and server +# Build the server and client RUN npm run build:server RUN npm run build:prd diff --git a/client/src/features/homepage/HomePage.tsx b/client/src/features/homepage/HomePage.tsx index 3241da8..917236d 100644 --- a/client/src/features/homepage/HomePage.tsx +++ b/client/src/features/homepage/HomePage.tsx @@ -30,7 +30,7 @@ const HomePage: React.FC = () => {

Welcome to SkyScraper

-

CI/CD 2

+

CI/CD

{' '}