From b65b3f0388d308b6c78413a20f0b8d2720e2d024 Mon Sep 17 00:00:00 2001 From: santhosh Date: Sun, 15 Mar 2020 23:29:38 +0530 Subject: [PATCH 01/33] updated buildspec.yml for codebuild --- Dockerfile | 31 +++++++++++++++++++++++ buildspec.yml | 26 +++++++++++++++++++ src/main/resources/application.properties | 6 ++--- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 buildspec.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e3eee1b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM centos:centos7 + +# Yum workaround to stalled mirror +RUN sed -i -e 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/fastestmirror.conf +RUN sed -i -e 's$\#baseurl\=http\:\/\/mirror.centos.org\/centos\/\$releasever\/updates\/\$basearch\/$baseurl\=http\:\/\/mirror.centos.org\/centos\/\$releasever\/updates\/\$basearch\/$g' /etc/yum.repos.d/CentOS-Base.repo + +RUN rm -f /var/lib/rpm/__* +RUN rpm --rebuilddb -v -v +RUN yum clean all + +ENV CA_CERTIFICATES_JAVA_VERSION 20140324 + +RUN yum -y update nss nss-softokn nss-softokn-freebl nss-util sqlite +RUN yum -v install -y \ + wget \ + zip \ + openssh-client \ + unzip \ + java-1.8.0-openjdk \ + && yum clean all + +COPY target/*jar /home/ec2-user/ + +RUN chmod -R 777 /home/ec2-user/ + +# Expose ports. +EXPOSE 8080 +EXPOSE 443 + +WORKDIR /home/ec2-user +CMD ["java", "-jar", "easy-notes-1.0.0.jar"] diff --git a/buildspec.yml b/buildspec.yml new file mode 100644 index 0000000..5f21043 --- /dev/null +++ b/buildspec.yml @@ -0,0 +1,26 @@ +version: 0.2 + +phases: + pre_build: + commands: + - echo Logging in to Amazon ECR... + - aws --version + - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) + - REPOSITORY_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test + - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) + - IMAGE_TAG=${COMMIT_HASH:=latest} + build: + commands: + - echo Build started on `date` + - echo Building the Docker image... + - docker build -t $REPOSITORY_URI:latest . + - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG + post_build: + commands: + - echo Build completed on `date` + - echo Pushing the Docker images... + - docker push $REPOSITORY_URI:latest + - docker push $REPOSITORY_URI:$IMAGE_TAG + - printf '[{"name":"hello-world","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json +artifacts: + files: imagedefinitions.json diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d357d46..a4b39a0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ ## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false -spring.datasource.username = root -spring.datasource.password = callicoder +spring.datasource.username = demouser +spring.datasource.password = demopassword@! ## Hibernate Properties @@ -10,4 +10,4 @@ spring.datasource.password = callicoder spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect # Hibernate ddl auto (create, create-drop, validate, update) -spring.jpa.hibernate.ddl-auto = update \ No newline at end of file +spring.jpa.hibernate.ddl-auto = update From e654790e07946bf3feb99b5c88a39e9f6ad4bc1b Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Sun, 15 Mar 2020 23:43:37 +0530 Subject: [PATCH 02/33] fixed intendations --- buildspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yml b/buildspec.yml index 5f21043..ca104b7 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -21,6 +21,6 @@ phases: - echo Pushing the Docker images... - docker push $REPOSITORY_URI:latest - docker push $REPOSITORY_URI:$IMAGE_TAG - - printf '[{"name":"hello-world","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json + - printf '[{"name":"hello-world","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json artifacts: files: imagedefinitions.json From 531fc73735bf84deed3ee299dbe91e7c9d00fd25 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 01:13:08 +0530 Subject: [PATCH 03/33] updated buildspec.yml --- buildspec.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index ca104b7..11f68e5 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -1,6 +1,14 @@ version: 0.2 phases: + install: + commands: + - apt-get update -y + - apt-get install -y software-properties-common + - add-apt-repository ppa:openjdk-r/ppa + - apt-get update -y + - apt-get install -y openjdk-8-jdk + - apt-get install -y maven pre_build: commands: - echo Logging in to Amazon ECR... @@ -12,15 +20,18 @@ phases: build: commands: - echo Build started on `date` - - echo Building the Docker image... + - echo Building the Application image... + - mvn package + - echo Building the Docker image... - docker build -t $REPOSITORY_URI:latest . - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG post_build: commands: + commands: - echo Build completed on `date` - echo Pushing the Docker images... - docker push $REPOSITORY_URI:latest - docker push $REPOSITORY_URI:$IMAGE_TAG - - printf '[{"name":"hello-world","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json + - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json artifacts: files: imagedefinitions.json From 2f097a1b20cb242db85c011ff26b6af0a21b7107 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 01:13:57 +0530 Subject: [PATCH 04/33] removed extra spaces --- buildspec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 11f68e5..1a4b024 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -22,7 +22,7 @@ phases: - echo Build started on `date` - echo Building the Application image... - mvn package - - echo Building the Docker image... + - echo Building the Docker image... - docker build -t $REPOSITORY_URI:latest . - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG post_build: @@ -32,6 +32,6 @@ phases: - echo Pushing the Docker images... - docker push $REPOSITORY_URI:latest - docker push $REPOSITORY_URI:$IMAGE_TAG - - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json + - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json artifacts: files: imagedefinitions.json From 984dbe5a12c32e05d9d08bec5424816f60ec2983 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 01:18:16 +0530 Subject: [PATCH 05/33] removed duplicates --- buildspec.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/buildspec.yml b/buildspec.yml index 1a4b024..b45cce6 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -27,7 +27,6 @@ phases: - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG post_build: commands: - commands: - echo Build completed on `date` - echo Pushing the Docker images... - docker push $REPOSITORY_URI:latest From 9edb97f4a0f23e18a4a7464cd59f1eacfc3bf19a Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 01:39:25 +0530 Subject: [PATCH 06/33] updated hostname --- src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a4b39a0..b5a4829 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ ## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) -spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false +spring.datasource.url = jdbc:mysql://demo-db-cluster.cluster-cmzigdlgs0to.ap-southeast-1.rds.amazonaws.com:3306/notes_app?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false spring.datasource.username = demouser -spring.datasource.password = demopassword@! +spring.datasource.password = demoPassword ## Hibernate Properties From 3a8dce0350ac15cba0fed72c40f4575d99428996 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 01:43:04 +0530 Subject: [PATCH 07/33] Update application.properties --- src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b5a4829..6555fa2 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ ## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) -spring.datasource.url = jdbc:mysql://demo-db-cluster.cluster-cmzigdlgs0to.ap-southeast-1.rds.amazonaws.com:3306/notes_app?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false +spring.datasource.url = jdbc:mysql://demoabc-db-cluster.cluster-cmzigdlgs0to.ap-southeast-1.rds.amazonaws.com:3306/notes_app?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false spring.datasource.username = demouser -spring.datasource.password = demoPassword +spring.datasource.password = demoPassword@123 ## Hibernate Properties From be4f1242d312e643004980d31ed245f0fe318963 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 06:41:15 +0530 Subject: [PATCH 08/33] updated .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index ff29930..e08816a 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,7 @@ dist/ nbdist/ .nb-gradle/ .elasticbeanstalk + +##Docker spec## +Dockerfile +buildspec.yml From 5d93bb8caa05d5c1cfd0bc0dcebffb5f4128fe5c Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 06:44:47 +0530 Subject: [PATCH 09/33] updated db hostname --- src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 6555fa2..b5a4829 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ ## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) -spring.datasource.url = jdbc:mysql://demoabc-db-cluster.cluster-cmzigdlgs0to.ap-southeast-1.rds.amazonaws.com:3306/notes_app?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false +spring.datasource.url = jdbc:mysql://demo-db-cluster.cluster-cmzigdlgs0to.ap-southeast-1.rds.amazonaws.com:3306/notes_app?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false spring.datasource.username = demouser -spring.datasource.password = demoPassword@123 +spring.datasource.password = demoPassword ## Hibernate Properties From f12a88cd76b4110c17ea936087d257802e1b322b Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 07:18:34 +0530 Subject: [PATCH 10/33] updated cache --- buildspec.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buildspec.yml b/buildspec.yml index b45cce6..0fc26d4 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -34,3 +34,6 @@ phases: - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json artifacts: files: imagedefinitions.json +cache: + paths: + - '/root/.m2/**/*' From f0b2349f471107da8562b4f0feef854c373c3d2c Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 09:38:08 +0530 Subject: [PATCH 11/33] updated docker version --- buildspec.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/buildspec.yml b/buildspec.yml index 0fc26d4..bc72e51 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -13,6 +13,7 @@ phases: commands: - echo Logging in to Amazon ECR... - aws --version + - docker --version - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) - REPOSITORY_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) From 58e83207f9f0d4e2141250261db3c6196f22a9b7 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 09:38:41 +0530 Subject: [PATCH 12/33] Update buildspec.yml --- buildspec.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildspec.yml b/buildspec.yml index bc72e51..49f17cb 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -3,6 +3,8 @@ version: 0.2 phases: install: commands: + - aws --version + - docker --version - apt-get update -y - apt-get install -y software-properties-common - add-apt-repository ppa:openjdk-r/ppa From 28c908c3ad56bcfa2928f598fb6b5f2a950a526e Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 09:56:36 +0530 Subject: [PATCH 13/33] updated docker workdir --- Dockerfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index e3eee1b..3b08015 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,17 +10,12 @@ RUN yum clean all ENV CA_CERTIFICATES_JAVA_VERSION 20140324 -RUN yum -y update nss nss-softokn nss-softokn-freebl nss-util sqlite RUN yum -v install -y \ wget \ - zip \ - openssh-client \ - unzip \ java-1.8.0-openjdk \ && yum clean all - +RUN mkdir -p /home/ec2-user COPY target/*jar /home/ec2-user/ - RUN chmod -R 777 /home/ec2-user/ # Expose ports. From 40a8c7ffcc6f96d13863932ff8622fe317077595 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 10:06:09 +0530 Subject: [PATCH 14/33] Update Dockerfile --- Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b08015..60afbd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,6 @@ FROM centos:centos7 # Yum workaround to stalled mirror RUN sed -i -e 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/fastestmirror.conf RUN sed -i -e 's$\#baseurl\=http\:\/\/mirror.centos.org\/centos\/\$releasever\/updates\/\$basearch\/$baseurl\=http\:\/\/mirror.centos.org\/centos\/\$releasever\/updates\/\$basearch\/$g' /etc/yum.repos.d/CentOS-Base.repo - -RUN rm -f /var/lib/rpm/__* -RUN rpm --rebuilddb -v -v RUN yum clean all ENV CA_CERTIFICATES_JAVA_VERSION 20140324 From cd9b6fcd60584ce2e50eb84946d0f5f04bb74912 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 10:56:43 +0530 Subject: [PATCH 15/33] updated gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e08816a..0ee93e2 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ nbdist/ ##Docker spec## Dockerfile buildspec.yml +*.yml From 131085289c5984bb5f96046d253acc31f487d702 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 12:14:23 +0530 Subject: [PATCH 16/33] updated docker image tags --- buildspec.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 49f17cb..882dd4e 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -3,8 +3,6 @@ version: 0.2 phases: install: commands: - - aws --version - - docker --version - apt-get update -y - apt-get install -y software-properties-common - add-apt-repository ppa:openjdk-r/ppa @@ -19,7 +17,8 @@ phases: - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) - REPOSITORY_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) - - IMAGE_TAG=${COMMIT_HASH:=latest} + #- IMAGE_TAG=${COMMIT_HASH:=latest} + - ECR_IMAGE='demo-webapp' build: commands: - echo Build started on `date` @@ -27,14 +26,15 @@ phases: - mvn package - echo Building the Docker image... - docker build -t $REPOSITORY_URI:latest . - - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG + - docker tag "${ECR_IMAGE}:latest" "$REPOSITORY_URI:${ECR_IMAGE}" + #- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG post_build: commands: - echo Build completed on `date` - echo Pushing the Docker images... - - docker push $REPOSITORY_URI:latest - - docker push $REPOSITORY_URI:$IMAGE_TAG - - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json + #- docker push $REPOSITORY_URI:latest + - docker push $REPOSITORY_URI:$ECR_IMAGE + - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$ECR_IMAGE > imagedefinitions.json artifacts: files: imagedefinitions.json cache: From ebbe258fb1bb5e9c03dfa076d521848f97d63f61 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 12:53:49 +0530 Subject: [PATCH 17/33] updated buildspec --- buildspec.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 882dd4e..c45477c 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -17,8 +17,7 @@ phases: - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) - REPOSITORY_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) - #- IMAGE_TAG=${COMMIT_HASH:=latest} - - ECR_IMAGE='demo-webapp' + - IMAGE_TAG=${COMMIT_HASH:=latest} build: commands: - echo Build started on `date` @@ -26,15 +25,14 @@ phases: - mvn package - echo Building the Docker image... - docker build -t $REPOSITORY_URI:latest . - - docker tag "${ECR_IMAGE}:latest" "$REPOSITORY_URI:${ECR_IMAGE}" - #- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG + docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG post_build: commands: - echo Build completed on `date` - echo Pushing the Docker images... #- docker push $REPOSITORY_URI:latest - docker push $REPOSITORY_URI:$ECR_IMAGE - - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$ECR_IMAGE > imagedefinitions.json + - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json artifacts: files: imagedefinitions.json cache: From f2ad5541418a75d30fe99a68a2bcd148fdc035f6 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 12:56:02 +0530 Subject: [PATCH 18/33] Update buildspec.yml --- buildspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yml b/buildspec.yml index c45477c..a54a555 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -25,7 +25,7 @@ phases: - mvn package - echo Building the Docker image... - docker build -t $REPOSITORY_URI:latest . - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG + - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG post_build: commands: - echo Build completed on `date` From 816f4205e4cd37bac252a3c04bbf7952e7745eda Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 13:39:32 +0530 Subject: [PATCH 19/33] Update buildspec.yml --- buildspec.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index a54a555..8ea0c8d 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -13,7 +13,6 @@ phases: commands: - echo Logging in to Amazon ECR... - aws --version - - docker --version - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) - REPOSITORY_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) @@ -23,18 +22,17 @@ phases: - echo Build started on `date` - echo Building the Application image... - mvn package - - echo Building the Docker image... - - docker build -t $REPOSITORY_URI:latest . - - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG + - echo Building the Docker image... + #- docker build -t $REPOSITORY_URI:latest . + - docker build -t $REPOSITORY_URI . + - docker tag $REPOSITORY_URI $REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:} post_build: commands: + commands: - echo Build completed on `date` - echo Pushing the Docker images... - #- docker push $REPOSITORY_URI:latest - - docker push $REPOSITORY_URI:$ECR_IMAGE - - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json + - docker push $REPOSITORY_URI:latest + - docker push $REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:} + - "echo {\\\"image\\\":\\\"$REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:}\\\"} > imagedefinitions.json" artifacts: files: imagedefinitions.json -cache: - paths: - - '/root/.m2/**/*' From b0bcd89ed0f1ff9fedb6f0a6b8c5fa8619df09ce Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 13:40:26 +0530 Subject: [PATCH 20/33] updated docker tag --- buildspec.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 8ea0c8d..b2251a6 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -22,9 +22,8 @@ phases: - echo Build started on `date` - echo Building the Application image... - mvn package - - echo Building the Docker image... - #- docker build -t $REPOSITORY_URI:latest . - - docker build -t $REPOSITORY_URI . + - echo Building the Docker image... + - docker build -t $REPOSITORY_URI . - docker tag $REPOSITORY_URI $REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:} post_build: commands: @@ -33,6 +32,6 @@ phases: - echo Pushing the Docker images... - docker push $REPOSITORY_URI:latest - docker push $REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:} - - "echo {\\\"image\\\":\\\"$REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:}\\\"} > imagedefinitions.json" + - "echo {\\\"image\\\":\\\"$REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:}\\\"} > imagedefinitions.json" artifacts: files: imagedefinitions.json From 77fa736319cc6bd2d3e499f80bf0c4e5269be287 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 15:09:12 +0530 Subject: [PATCH 21/33] removed duplicates --- buildspec.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/buildspec.yml b/buildspec.yml index b2251a6..b7795d4 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -27,7 +27,6 @@ phases: - docker tag $REPOSITORY_URI $REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:} post_build: commands: - commands: - echo Build completed on `date` - echo Pushing the Docker images... - docker push $REPOSITORY_URI:latest From b5687cadf4fe1480cfe30dad7308fd8c09ea95f2 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 18:55:56 +0530 Subject: [PATCH 22/33] updated imagedefinitions.json --- buildspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yml b/buildspec.yml index b7795d4..2a5a087 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -31,6 +31,6 @@ phases: - echo Pushing the Docker images... - docker push $REPOSITORY_URI:latest - docker push $REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:} - - "echo {\\\"image\\\":\\\"$REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:}\\\"} > imagedefinitions.json" + - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json artifacts: files: imagedefinitions.json From e4df48826cb6ac969dc93d49aeb195b527f39ac1 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 19:16:38 +0530 Subject: [PATCH 23/33] Update buildspec.yml --- buildspec.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 2a5a087..077a78d 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -22,15 +22,15 @@ phases: - echo Build started on `date` - echo Building the Application image... - mvn package - - echo Building the Docker image... - - docker build -t $REPOSITORY_URI . - - docker tag $REPOSITORY_URI $REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:} + - echo Building the Docker image... + - docker build -t $REPOSITORY_URI . + - docker tag $REPOSITORY_URI $REPOSITORY_URI:latest post_build: commands: + commands: - echo Build completed on `date` - echo Pushing the Docker images... - docker push $REPOSITORY_URI:latest - - docker push $REPOSITORY_URI:${CODEBUILD_BUILD_ID##*:} - - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json + - printf '[{"name":"demo-test-web","imageUri":"$REPOSITORY_URI"}]' > imagedefinitions.json artifacts: files: imagedefinitions.json From 471b0b9dfacd53742a189f38f01b4b98f8740bac Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 19:19:51 +0530 Subject: [PATCH 24/33] updated with docker tag --- buildspec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 077a78d..b67244a 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -22,8 +22,8 @@ phases: - echo Build started on `date` - echo Building the Application image... - mvn package - - echo Building the Docker image... - - docker build -t $REPOSITORY_URI . + - echo Building the Docker image... + - docker build -t $REPOSITORY_URI . - docker tag $REPOSITORY_URI $REPOSITORY_URI:latest post_build: commands: From 758cc328093ffd344f20655187a242fa65c8e9c0 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 19:22:50 +0530 Subject: [PATCH 25/33] updated syntax --- buildspec.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index b67244a..d636424 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -27,10 +27,9 @@ phases: - docker tag $REPOSITORY_URI $REPOSITORY_URI:latest post_build: commands: - commands: - echo Build completed on `date` - echo Pushing the Docker images... - docker push $REPOSITORY_URI:latest - - printf '[{"name":"demo-test-web","imageUri":"$REPOSITORY_URI"}]' > imagedefinitions.json + - printf '[{"name":"demo-test-web","imageUri":"$REPOSITORY_URI"}]' > imagedefinitions.json artifacts: files: imagedefinitions.json From ec00fa27ba58588da4f5739fe24204c88acfbf62 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 19:36:36 +0530 Subject: [PATCH 26/33] updated new buildspec.yml --- buildspec.yml | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index d636424..fe0161b 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -1,35 +1,29 @@ version: 0.2 - phases: - install: - commands: - - apt-get update -y - - apt-get install -y software-properties-common - - add-apt-repository ppa:openjdk-r/ppa - - apt-get update -y - - apt-get install -y openjdk-8-jdk - - apt-get install -y maven pre_build: commands: - echo Logging in to Amazon ECR... - aws --version - - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) - - REPOSITORY_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) - - IMAGE_TAG=${COMMIT_HASH:=latest} + - eval $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) + - REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME + - IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) build: commands: - echo Build started on `date` - - echo Building the Application image... + - echo Building the Application image... - mvn package - echo Building the Docker image... - - docker build -t $REPOSITORY_URI . - - docker tag $REPOSITORY_URI $REPOSITORY_URI:latest + - REPO_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME + - docker pull $REPO_URI:latest || true + - docker build --cache-from $REPO_URI:latest --tag $REPO_URI:latest --tag $REPO_URI:$IMAGE_TAG . post_build: commands: - echo Build completed on `date` - echo Pushing the Docker images... - - docker push $REPOSITORY_URI:latest - - printf '[{"name":"demo-test-web","imageUri":"$REPOSITORY_URI"}]' > imagedefinitions.json + - REPO_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME + - docker push $REPO_URI:latest + - docker push $REPO_URI:$IMAGE_TAG + - echo Writing image definitions file... + - printf '[{"name":"%s","imageUri":"%s"}]' "$CONTAINER_NAME" "$REPO_URI:$IMAGE_TAG" | tee imagedefinitions.json artifacts: - files: imagedefinitions.json + files: imagedefinitions.json From 66d9e91a20ec58eb12676929f5e11c8b09d3006e Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 19:38:08 +0530 Subject: [PATCH 27/33] Update buildspec.yml --- buildspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yml b/buildspec.yml index fe0161b..57e7b88 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -10,7 +10,7 @@ phases: build: commands: - echo Build started on `date` - - echo Building the Application image... + - echo Building the Application image... - mvn package - echo Building the Docker image... - REPO_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME From 550a475920639a0d18219f34062e033670816984 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 19:51:04 +0530 Subject: [PATCH 28/33] Update buildspec.yml --- buildspec.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 57e7b88..db09892 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -5,7 +5,7 @@ phases: - echo Logging in to Amazon ECR... - aws --version - eval $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) - - REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME + - REPO_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) build: commands: @@ -13,14 +13,14 @@ phases: - echo Building the Application image... - mvn package - echo Building the Docker image... - - REPO_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME - - docker pull $REPO_URI:latest || true - - docker build --cache-from $REPO_URI:latest --tag $REPO_URI:latest --tag $REPO_URI:$IMAGE_TAG . + - REPO_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test + - docker build -t $REPOSITORY_URI . + - docker tag "$CONTAINER_NAME:latest" $REPO_URI post_build: commands: - echo Build completed on `date` - echo Pushing the Docker images... - - REPO_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME + - REPO_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - docker push $REPO_URI:latest - docker push $REPO_URI:$IMAGE_TAG - echo Writing image definitions file... From 77bdc27f7b9a37a734c7375aedd4ae760a89d9e9 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 19:57:00 +0530 Subject: [PATCH 29/33] Update buildspec.yml --- buildspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildspec.yml b/buildspec.yml index db09892..6738d63 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -14,7 +14,7 @@ phases: - mvn package - echo Building the Docker image... - REPO_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - - docker build -t $REPOSITORY_URI . + - docker build -t $REPO_URI . - docker tag "$CONTAINER_NAME:latest" $REPO_URI post_build: commands: From 53ae461211055980d9b5c40410fe4671407e4162 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 20:11:56 +0530 Subject: [PATCH 30/33] updated docker push --- buildspec.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 6738d63..6511265 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -15,15 +15,16 @@ phases: - echo Building the Docker image... - REPO_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - docker build -t $REPO_URI . - - docker tag "$CONTAINER_NAME:latest" $REPO_URI + - docker tag demo-test-web:latest $REPO_URI post_build: commands: - echo Build completed on `date` - echo Pushing the Docker images... - REPO_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - - docker push $REPO_URI:latest + - docker push $REPO_URI:demo-test-web - docker push $REPO_URI:$IMAGE_TAG + - docker push $REPO_URI:latest - echo Writing image definitions file... - - printf '[{"name":"%s","imageUri":"%s"}]' "$CONTAINER_NAME" "$REPO_URI:$IMAGE_TAG" | tee imagedefinitions.json + - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPO_URI:$IMAGE_TAG > imagedefinitions.json artifacts: files: imagedefinitions.json From d809587402d00f4439ef6f3b53977a7974dff34d Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 20:29:32 +0530 Subject: [PATCH 31/33] Update buildspec.yml --- buildspec.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 6511265..bda1783 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -15,15 +15,14 @@ phases: - echo Building the Docker image... - REPO_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - docker build -t $REPO_URI . - - docker tag demo-test-web:latest $REPO_URI + - docker tag $REPO_URI $REPO_URI:demo-test-web post_build: commands: - echo Build completed on `date` - echo Pushing the Docker images... - REPO_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - - docker push $REPO_URI:demo-test-web - - docker push $REPO_URI:$IMAGE_TAG - docker push $REPO_URI:latest + - docker push $REPO_URI:demo-test-web - echo Writing image definitions file... - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPO_URI:$IMAGE_TAG > imagedefinitions.json artifacts: From d1d6ae21b465fbeaf71af67cbbb6c92cd584e987 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Mon, 16 Mar 2020 20:48:47 +0530 Subject: [PATCH 32/33] updated docker tag --- buildspec.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index bda1783..00234f4 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -15,15 +15,15 @@ phases: - echo Building the Docker image... - REPO_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - docker build -t $REPO_URI . - - docker tag $REPO_URI $REPO_URI:demo-test-web + - docker tag $REPO_URI $REPO_URI:${CODEBUILD_BUILD_ID##*:} post_build: commands: - echo Build completed on `date` - echo Pushing the Docker images... - REPO_URI=891076391930.dkr.ecr.ap-southeast-1.amazonaws.com/demo-test - - docker push $REPO_URI:latest - - docker push $REPO_URI:demo-test-web + #- docker push $REPO_URI:latest + - docker push $REPO_URI:${CODEBUILD_BUILD_ID##*:} - echo Writing image definitions file... - - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPO_URI:$IMAGE_TAG > imagedefinitions.json + - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPO_URI:${CODEBUILD_BUILD_ID##*:} > imagedefinitions.json artifacts: files: imagedefinitions.json From 0c968d9f7b6311b45e3e2a794cea5a6fcb8eb221 Mon Sep 17 00:00:00 2001 From: Santhosh Venkatraman Date: Thu, 19 Mar 2020 18:01:42 +0530 Subject: [PATCH 33/33] Dummy changes --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0ee93e2..96143d0 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,7 @@ nbdist/ .nb-gradle/ .elasticbeanstalk -##Docker spec## +##Docker spec#### Dockerfile buildspec.yml *.yml