From a640850b1e54ae19d654007dfd45349944ef8d33 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:06:17 +0500 Subject: [PATCH 01/20] Delete EKS_Terraform directory --- EKS_Terraform/main.tf | 175 ------------------------------------- EKS_Terraform/output.tf | 15 ---- EKS_Terraform/variables.tf | 5 -- 3 files changed, 195 deletions(-) delete mode 100644 EKS_Terraform/main.tf delete mode 100644 EKS_Terraform/output.tf delete mode 100644 EKS_Terraform/variables.tf diff --git a/EKS_Terraform/main.tf b/EKS_Terraform/main.tf deleted file mode 100644 index cf18a035..00000000 --- a/EKS_Terraform/main.tf +++ /dev/null @@ -1,175 +0,0 @@ -provider "aws" { - region = "ap-south-1" -} - -resource "aws_vpc" "devopsshack_vpc" { - cidr_block = "10.0.0.0/16" - - tags = { - Name = "devopsshack-vpc" - } -} - -resource "aws_subnet" "devopsshack_subnet" { - count = 2 - vpc_id = aws_vpc.devopsshack_vpc.id - cidr_block = cidrsubnet(aws_vpc.devopsshack_vpc.cidr_block, 8, count.index) - availability_zone = element(["ap-south-1a", "ap-south-1b"], count.index) - map_public_ip_on_launch = true - - tags = { - Name = "devopsshack-subnet-${count.index}" - } -} - -resource "aws_internet_gateway" "devopsshack_igw" { - vpc_id = aws_vpc.devopsshack_vpc.id - - tags = { - Name = "devopsshack-igw" - } -} - -resource "aws_route_table" "devopsshack_route_table" { - vpc_id = aws_vpc.devopsshack_vpc.id - - route { - cidr_block = "0.0.0.0/0" - gateway_id = aws_internet_gateway.devopsshack_igw.id - } - - tags = { - Name = "devopsshack-route-table" - } -} - -resource "aws_route_table_association" "a" { - count = 2 - subnet_id = aws_subnet.devopsshack_subnet[count.index].id - route_table_id = aws_route_table.devopsshack_route_table.id -} - -resource "aws_security_group" "devopsshack_cluster_sg" { - vpc_id = aws_vpc.devopsshack_vpc.id - - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - - tags = { - Name = "devopsshack-cluster-sg" - } -} - -resource "aws_security_group" "devopsshack_node_sg" { - vpc_id = aws_vpc.devopsshack_vpc.id - - ingress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - - tags = { - Name = "devopsshack-node-sg" - } -} - -resource "aws_eks_cluster" "devopsshack" { - name = "devopsshack-cluster" - role_arn = aws_iam_role.devopsshack_cluster_role.arn - - vpc_config { - subnet_ids = aws_subnet.devopsshack_subnet[*].id - security_group_ids = [aws_security_group.devopsshack_cluster_sg.id] - } -} - -resource "aws_eks_node_group" "devopsshack" { - cluster_name = aws_eks_cluster.devopsshack.name - node_group_name = "devopsshack-node-group" - node_role_arn = aws_iam_role.devopsshack_node_group_role.arn - subnet_ids = aws_subnet.devopsshack_subnet[*].id - - scaling_config { - desired_size = 3 - max_size = 3 - min_size = 3 - } - - instance_types = ["t2.large"] - - remote_access { - ec2_ssh_key = var.ssh_key_name - source_security_group_ids = [aws_security_group.devopsshack_node_sg.id] - } -} - -resource "aws_iam_role" "devopsshack_cluster_role" { - name = "devopsshack-cluster-role" - - assume_role_policy = < Date: Thu, 5 Sep 2024 15:45:41 +0500 Subject: [PATCH 02/20] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 3ed8ab2b..425a6fe0 100644 --- a/pom.xml +++ b/pom.xml @@ -102,11 +102,11 @@ maven-releases - http://13.235.245.200:8081/repository/maven-releases/ + http://15.152.109.67:8081/repository/maven-releases/ maven-snapshots - http://13.235.245.200:8081/repository/maven-snapshots/ + http://15.152.109.67:8081/repository/maven-snapshots/ From ea77bf5af4dd9e357342e9f19a31d97130b5083a Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:38:22 +0500 Subject: [PATCH 03/20] Update deployment-service.yml --- deployment-service.yml | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/deployment-service.yml b/deployment-service.yml index 31aec78b..a42ebe7e 100644 --- a/deployment-service.yml +++ b/deployment-service.yml @@ -1,35 +1,47 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: webapps + +--- + apiVersion: apps/v1 kind: Deployment metadata: - name: bloggingapp-deployment + name: nginx-deployment + namespace: webapps + labels: + app: bank-app spec: + replicas: 3 selector: matchLabels: - app: bloggingapp - replicas: 2 + app: bank-app template: metadata: labels: - app: bloggingapp + app: bank-app spec: containers: - - name: bloggingapp - image: adijaiswal/bloggingapp:latest # Updated image to private DockerHub image - imagePullPolicy: Always - ports: - - containerPort: 8080 + - name: my-container + image: za357627acc1/project:latest + ports: + - containerPort: 8080 imagePullSecrets: - - name: regcred # Reference to the Docker registry secret + - name: my-registry-secret + --- + apiVersion: v1 kind: Service metadata: - name: bloggingapp-ssvc + name: my-loadbalancer-service + namespace: webapps spec: + type: LoadBalancer selector: - app: bloggingapp + app: bank-app ports: - - protocol: "TCP" + - protocol: TCP port: 80 - targetPort: 8080 - type: LoadBalancer + targetPort: 8080 From f89cf0b17f46756f2490cbcddd4b872c89de6af2 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:13:23 +0500 Subject: [PATCH 04/20] Create buildspec.yaml --- buildspec.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 buildspec.yaml diff --git a/buildspec.yaml b/buildspec.yaml new file mode 100644 index 00000000..3f33b13f --- /dev/null +++ b/buildspec.yaml @@ -0,0 +1,35 @@ +version: 0.2 + +phases: + install: + runtime-versions: + java: openjdk17 # Adjust Java version if needed + commands: + - echo "Installing Maven and Docker..." + - mvn -version + - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 034362047502.dkr.ecr.us-east-1.amazonaws.com + pre_build: + commands: + - echo "Pulling dependencies from Nexus based on pom.xml..." + - mvn clean install -DskipTests=true # Skip tests to speed up the process; you can enable them if required + build: + commands: + - echo "Building the project with Maven..." + - mvn package + - echo "Building Docker image..." + - docker build -t moiz/project . + - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest + post_build: + commands: + - echo "Pushing Docker image to Amazon ECR..." + - docker push 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest + - echo "Build completed successfully!" +artifacts: + files: + - target/*.jar # Change this based on what files you want to upload + name: my-application-artifact.zip + discard-paths: yes + base-directory: target # The directory where your build artifacts (like JAR) are stored +cache: + paths: + - '/root/.m2/**/*' # Cache Maven dependencies to speed up subsequent builds From 3a9f3f70fd7491b64ec1c783f4fb56f89c058fe8 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:14:28 +0500 Subject: [PATCH 05/20] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 425a6fe0..f224b4c0 100644 --- a/pom.xml +++ b/pom.xml @@ -102,11 +102,11 @@ maven-releases - http://15.152.109.67:8081/repository/maven-releases/ + http://23.22.137.160:8081/repository/maven-releases/ maven-snapshots - http://15.152.109.67:8081/repository/maven-snapshots/ + http://23.22.137.160:8081/repository/maven-snapshots/ From c810f6191608d1cfa20c579cd0cdc198a3e27e9f Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:17:27 +0500 Subject: [PATCH 06/20] Update buildspec.yaml --- buildspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yaml b/buildspec.yaml index 3f33b13f..bae98d2c 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -3,7 +3,7 @@ version: 0.2 phases: install: runtime-versions: - java: openjdk17 # Adjust Java version if needed + java: corretto17 # Adjust Java version if needed commands: - echo "Installing Maven and Docker..." - mvn -version From de5eefe9ae754490d4ec888eb899e237252f60a7 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:35:13 +0500 Subject: [PATCH 07/20] Update buildspec.yaml --- buildspec.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildspec.yaml b/buildspec.yaml index bae98d2c..39a54f1b 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -16,6 +16,8 @@ phases: commands: - echo "Building the project with Maven..." - mvn package + - echo "Contents of the target directory:" + - ls -la target # List files to verify output - echo "Building Docker image..." - docker build -t moiz/project . - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest From 5c30b60ec0bd253986c8db4ae3b74a83a707b02b Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:41:54 +0500 Subject: [PATCH 08/20] Update buildspec.yaml --- buildspec.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/buildspec.yaml b/buildspec.yaml index 39a54f1b..2b4bf862 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -16,8 +16,6 @@ phases: commands: - echo "Building the project with Maven..." - mvn package - - echo "Contents of the target directory:" - - ls -la target # List files to verify output - echo "Building Docker image..." - docker build -t moiz/project . - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest @@ -28,7 +26,7 @@ phases: - echo "Build completed successfully!" artifacts: files: - - target/*.jar # Change this based on what files you want to upload + - target/twitter-app-0.0.3.jar # Specify the exact JAR file name name: my-application-artifact.zip discard-paths: yes base-directory: target # The directory where your build artifacts (like JAR) are stored From 541fea0749afa3b8f6ed578e83c9f7acc220bbda Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:48:40 +0500 Subject: [PATCH 09/20] Update buildspec.yaml --- buildspec.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildspec.yaml b/buildspec.yaml index 2b4bf862..f05db869 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -16,6 +16,8 @@ phases: commands: - echo "Building the project with Maven..." - mvn package + - echo "CHecking path" + - pwd - echo "Building Docker image..." - docker build -t moiz/project . - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest From e17a5868574dad1046fb916be11142e740a85fc9 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:53:20 +0500 Subject: [PATCH 10/20] Update buildspec.yaml --- buildspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/buildspec.yaml b/buildspec.yaml index f05db869..3abba2b7 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -18,6 +18,7 @@ phases: - mvn package - echo "CHecking path" - pwd + - ls -ltrh - echo "Building Docker image..." - docker build -t moiz/project . - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest From 58dc2fac772719efda378f44ecbce889bae42b70 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:55:58 +0500 Subject: [PATCH 11/20] Update buildspec.yaml --- buildspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yaml b/buildspec.yaml index 3abba2b7..a76bd216 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -29,7 +29,7 @@ phases: - echo "Build completed successfully!" artifacts: files: - - target/twitter-app-0.0.3.jar # Specify the exact JAR file name + - /codebuild/output/src23905962/src/github.com/Zayan-A/FullStack-Blogging-App/twitter-app-0.0.3.jar # Specify the exact JAR file name name: my-application-artifact.zip discard-paths: yes base-directory: target # The directory where your build artifacts (like JAR) are stored From 4246ceec31d3fa3e9f9509d5099a3b2bf5e826d0 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:58:19 +0500 Subject: [PATCH 12/20] Update buildspec.yaml --- buildspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yaml b/buildspec.yaml index a76bd216..7a4f394e 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -29,7 +29,7 @@ phases: - echo "Build completed successfully!" artifacts: files: - - /codebuild/output/src23905962/src/github.com/Zayan-A/FullStack-Blogging-App/twitter-app-0.0.3.jar # Specify the exact JAR file name + - codebuild/output/src23905962/src/github.com/Zayan-A/FullStack-Blogging-App/twitter-app-0.0.3.jar # Specify the exact JAR file name name: my-application-artifact.zip discard-paths: yes base-directory: target # The directory where your build artifacts (like JAR) are stored From 14564ca5ddbfc04d2f03c93bdd0531c8115035c9 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:00:54 +0500 Subject: [PATCH 13/20] Update buildspec.yaml --- buildspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yaml b/buildspec.yaml index 7a4f394e..5b73d5e7 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -29,7 +29,7 @@ phases: - echo "Build completed successfully!" artifacts: files: - - codebuild/output/src23905962/src/github.com/Zayan-A/FullStack-Blogging-App/twitter-app-0.0.3.jar # Specify the exact JAR file name + - codebuild/output/src23905962/src/github.com/Zayan-A/FullStack-Blogging-App/target/twitter-app-0.0.3.jar # Specify the exact JAR file name name: my-application-artifact.zip discard-paths: yes base-directory: target # The directory where your build artifacts (like JAR) are stored From 4986339ab335501cdf5b3af51faae9099bd95d03 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:04:36 +0500 Subject: [PATCH 14/20] Update buildspec.yaml --- buildspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yaml b/buildspec.yaml index 5b73d5e7..ac71415a 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -18,7 +18,7 @@ phases: - mvn package - echo "CHecking path" - pwd - - ls -ltrh + - target\ ls -ltrh - echo "Building Docker image..." - docker build -t moiz/project . - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest From 7b8f4bf15ccc8544d8bc627aa2eb0857da91080d Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:07:56 +0500 Subject: [PATCH 15/20] Update buildspec.yaml --- buildspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yaml b/buildspec.yaml index ac71415a..f1df94fd 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -18,7 +18,7 @@ phases: - mvn package - echo "CHecking path" - pwd - - target\ ls -ltrh + - ls -ltrh ./target - echo "Building Docker image..." - docker build -t moiz/project . - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest From 0caa30eeab8ebcf3b409702c24a7e162065abb26 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:12:52 +0500 Subject: [PATCH 16/20] Update buildspec.yaml --- buildspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yaml b/buildspec.yaml index f1df94fd..8e995c3d 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -29,7 +29,7 @@ phases: - echo "Build completed successfully!" artifacts: files: - - codebuild/output/src23905962/src/github.com/Zayan-A/FullStack-Blogging-App/target/twitter-app-0.0.3.jar # Specify the exact JAR file name + - codebuild/output/src23905962/src/github.com/Zayan-A/FullStack-Blogging-App/target/*.jar # Specify the exact JAR file name name: my-application-artifact.zip discard-paths: yes base-directory: target # The directory where your build artifacts (like JAR) are stored From 69f980095b177cacbe31bdbd2825fee1763e0218 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:19:01 +0500 Subject: [PATCH 17/20] Update buildspec.yaml --- buildspec.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/buildspec.yaml b/buildspec.yaml index 8e995c3d..478f7527 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -3,7 +3,7 @@ version: 0.2 phases: install: runtime-versions: - java: corretto17 # Adjust Java version if needed + java: corretto17 commands: - echo "Installing Maven and Docker..." - mvn -version @@ -11,14 +11,13 @@ phases: pre_build: commands: - echo "Pulling dependencies from Nexus based on pom.xml..." - - mvn clean install -DskipTests=true # Skip tests to speed up the process; you can enable them if required + - mvn clean install -DskipTests=true build: commands: - echo "Building the project with Maven..." - mvn package - - echo "CHecking path" - - pwd - - ls -ltrh ./target + - echo "Checking target directory contents:" + - ls -la target - echo "Building Docker image..." - docker build -t moiz/project . - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest @@ -28,11 +27,11 @@ phases: - docker push 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest - echo "Build completed successfully!" artifacts: + base-directory: target files: - - codebuild/output/src23905962/src/github.com/Zayan-A/FullStack-Blogging-App/target/*.jar # Specify the exact JAR file name + - twitter-app-0.0.3.jar name: my-application-artifact.zip discard-paths: yes - base-directory: target # The directory where your build artifacts (like JAR) are stored cache: paths: - - '/root/.m2/**/*' # Cache Maven dependencies to speed up subsequent builds + - '/root/.m2/**/*' From e4fb903890e5c071bf3997b724a99bb404c36d76 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:21:54 +0500 Subject: [PATCH 18/20] Update buildspec.yaml --- buildspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yaml b/buildspec.yaml index 478f7527..ca424fd7 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -24,7 +24,7 @@ phases: post_build: commands: - echo "Pushing Docker image to Amazon ECR..." - - docker push 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest + - docker push 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:v1 - echo "Build completed successfully!" artifacts: base-directory: target From a1a6c22c3e35756cc0e9e9ce192f092d13277497 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:22:15 +0500 Subject: [PATCH 19/20] Update buildspec.yaml --- buildspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yaml b/buildspec.yaml index ca424fd7..726d8185 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -20,7 +20,7 @@ phases: - ls -la target - echo "Building Docker image..." - docker build -t moiz/project . - - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:latest + - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:v1 post_build: commands: - echo "Pushing Docker image to Amazon ECR..." From 81506f2fcf33331c58200071998f6dc19124a519 Mon Sep 17 00:00:00 2001 From: Zayan-A <147820193+Zayan-A@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:30:45 +0500 Subject: [PATCH 20/20] Update buildspec.yaml --- buildspec.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/buildspec.yaml b/buildspec.yaml index 726d8185..8ba9c1e2 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -19,12 +19,13 @@ phases: - echo "Checking target directory contents:" - ls -la target - echo "Building Docker image..." - - docker build -t moiz/project . - - docker tag moiz/project:latest 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:v1 + - IMAGE_TAG=v1-$CODEBUILD_BUILD_NUMBER + - docker build -t moiz/project:$IMAGE_TAG . + - docker tag moiz/project:$IMAGE_TAG 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:$IMAGE_TAG post_build: commands: - echo "Pushing Docker image to Amazon ECR..." - - docker push 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:v1 + - docker push 034362047502.dkr.ecr.us-east-1.amazonaws.com/moiz/project:$IMAGE_TAG - echo "Build completed successfully!" artifacts: base-directory: target