diff --git a/.gitignore b/.gitignore index ff29930..96143d0 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,8 @@ dist/ nbdist/ .nb-gradle/ .elasticbeanstalk + +##Docker spec#### +Dockerfile +buildspec.yml +*.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..60afbd8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +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 yum clean all + +ENV CA_CERTIFICATES_JAVA_VERSION 20140324 + +RUN yum -v install -y \ + wget \ + 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. +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..00234f4 --- /dev/null +++ b/buildspec.yml @@ -0,0 +1,29 @@ +version: 0.2 +phases: + pre_build: + commands: + - echo Logging in to Amazon ECR... + - aws --version + - eval $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) + - 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: + - echo Build started on `date` + - echo Building the Application image... + - mvn package + - 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:${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:${CODEBUILD_BUILD_ID##*:} + - echo Writing image definitions file... + - printf '[{"name":"demo-test-web","imageUri":"%s"}]' $REPO_URI:${CODEBUILD_BUILD_ID##*:} > imagedefinitions.json +artifacts: + files: imagedefinitions.json diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d357d46..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.username = root -spring.datasource.password = callicoder +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 ## 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