From e9a31d95de0a642c356ecfe945d8fdcafec3d334 Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:47:18 +0500 Subject: [PATCH 01/11] Create Dockerfile --- Dockerfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a8fd89d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Use an official Node.js runtime as the base image +FROM node:21.7.3-alpine3.20 + +# Set the working directory in the container to /app +WORKDIR /app + +# Copy package.json and package-lock.json to the working directory +COPY package*.json ./ + +# Install the application dependencies +RUN npm install + +# Copy the rest of the application code to the working directory +COPY . . + +# Make port 8080 available outside the container +EXPOSE 3000 + +# Define the command to run the application +CMD [ "npm", "start" ] From 622d7f8bb97d3c5c7ae043767f62bcb8bbe7bcb8 Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:05:37 +0500 Subject: [PATCH 02/11] Create main.yml --- .github/workflows/main.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..af64309 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +name: Docker Image CI/CD + +on: + push: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: pulling the latest code + run: | + git branch + git switch main + git pull + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.SECRET_ACCESS }} + aws-region: us-east-1 + + - name: building the docker image + run: | + pwd + docker build -t cicd-backend . + docker images + + - name: push the image to ecr + run: | + docker tag cicd-backend:latest 119688269608.dkr.ecr.us-east-1.amazonaws.com/cicd-backend:latest + docker push 119688269608.dkr.ecr.us-east-1.amazonaws.com/cicd-backend:latest + + + + + + From 5276894648d929b0258889763076d6ca4f2cce80 Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:07:34 +0500 Subject: [PATCH 03/11] Update main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index af64309..59cb1a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,7 @@ jobs: steps: - name: pulling the latest code run: | + pwd git branch git switch main git pull From ac9168c7ff1f4d57b2aa251f4fba9db0714f4ff7 Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:08:29 +0500 Subject: [PATCH 04/11] Update main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 59cb1a6..a7f087a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,6 +12,7 @@ jobs: - name: pulling the latest code run: | pwd + ll git branch git switch main git pull From 47ea8794a59c975688cf409d32d38162cf989824 Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:20:39 +0500 Subject: [PATCH 05/11] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a7f087a..4fd9a6f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: - name: pulling the latest code run: | pwd - ll + ls -alsh git branch git switch main git pull From b1104d65b660a97b17c31682fec6d908182e4743 Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:22:47 +0500 Subject: [PATCH 06/11] Update main.yml --- .github/workflows/main.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4fd9a6f..5535a00 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: pulling the latest code run: | pwd @@ -34,9 +37,3 @@ jobs: run: | docker tag cicd-backend:latest 119688269608.dkr.ecr.us-east-1.amazonaws.com/cicd-backend:latest docker push 119688269608.dkr.ecr.us-east-1.amazonaws.com/cicd-backend:latest - - - - - - From 9e72d9265a710d26a2d474ebf64302b19585024d Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:26:01 +0500 Subject: [PATCH 07/11] Update main.yml --- .github/workflows/main.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5535a00..1c6e913 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,11 +21,10 @@ jobs: git pull - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.SECRET_ACCESS }} - aws-region: us-east-1 + run: | + echo "AWS_ACCESS_KEY_ID=${{ secrets.ACCESS_KEY }}" >> $GITHUB_ENV + echo "AWS_SECRET_ACCESS_KEY=${{ secrets.SECRET_ACCESS }}" >> $GITHUB_ENV + echo "AWS_REGION=us-east-1" >> $GITHUB_ENV - name: building the docker image run: | From 0481f472597179bccda03652aa60bb6c0d331a05 Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:32:08 +0500 Subject: [PATCH 08/11] Update main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c6e913..6d2bfdf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,5 +34,6 @@ jobs: - name: push the image to ecr run: | + aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 119688269608.dkr.ecr.us-east-1.amazonaws.com docker tag cicd-backend:latest 119688269608.dkr.ecr.us-east-1.amazonaws.com/cicd-backend:latest docker push 119688269608.dkr.ecr.us-east-1.amazonaws.com/cicd-backend:latest From a0aef80cba63d041845be6768e6c3ca6a7b2b225 Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:34:47 +0500 Subject: [PATCH 09/11] Update main.yml --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6d2bfdf..b7848d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,6 +26,10 @@ jobs: echo "AWS_SECRET_ACCESS_KEY=${{ secrets.SECRET_ACCESS }}" >> $GITHUB_ENV echo "AWS_REGION=us-east-1" >> $GITHUB_ENV + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + - name: building the docker image run: | pwd @@ -34,6 +38,5 @@ jobs: - name: push the image to ecr run: | - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 119688269608.dkr.ecr.us-east-1.amazonaws.com docker tag cicd-backend:latest 119688269608.dkr.ecr.us-east-1.amazonaws.com/cicd-backend:latest docker push 119688269608.dkr.ecr.us-east-1.amazonaws.com/cicd-backend:latest From 86025310db33eaa890d079ec02fa5e010de458cf Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:36:31 +0500 Subject: [PATCH 10/11] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b7848d9..c94e3b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,8 +22,8 @@ jobs: - name: Configure AWS credentials run: | - echo "AWS_ACCESS_KEY_ID=${{ secrets.ACCESS_KEY }}" >> $GITHUB_ENV - echo "AWS_SECRET_ACCESS_KEY=${{ secrets.SECRET_ACCESS }}" >> $GITHUB_ENV + echo "AWS_ACCESS_KEY_ID=AKIARXXP2B4UASKPPU77" >> $GITHUB_ENV + echo "AWS_SECRET_ACCESS_KEY=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" >> $GITHUB_ENV echo "AWS_REGION=us-east-1" >> $GITHUB_ENV - name: Login to Amazon ECR From 8a5e0d2ffa03923f462cf2bc71af0122801b9f91 Mon Sep 17 00:00:00 2001 From: ahmedtariqdatics <128350904+ahmedtariqdatics@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:37:47 +0500 Subject: [PATCH 11/11] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c94e3b2..b7848d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,8 +22,8 @@ jobs: - name: Configure AWS credentials run: | - echo "AWS_ACCESS_KEY_ID=AKIARXXP2B4UASKPPU77" >> $GITHUB_ENV - echo "AWS_SECRET_ACCESS_KEY=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" >> $GITHUB_ENV + echo "AWS_ACCESS_KEY_ID=${{ secrets.ACCESS_KEY }}" >> $GITHUB_ENV + echo "AWS_SECRET_ACCESS_KEY=${{ secrets.SECRET_ACCESS }}" >> $GITHUB_ENV echo "AWS_REGION=us-east-1" >> $GITHUB_ENV - name: Login to Amazon ECR