diff --git a/Docker-files/app/Dockerfile b/Docker-files/app/Dockerfile new file mode 100755 index 000000000..7865aa868 --- /dev/null +++ b/Docker-files/app/Dockerfile @@ -0,0 +1,13 @@ +FROM openjdk:11 AS BUILD_IMAGE +RUN apt update && apt install maven -y +RUN git clone https://github.com/Aboelkhair93/vprofile-project.git +RUN cd vprofile-project && git checkout docker && mvn install + +FROM tomcat:9-jre11 +LABEL "Project"="Vprofile" +LABEL "Author"="Aboelkhair93" +RUN rm -rf /usr/local/tomcat/webapps/* +COPY --from=BUILD_IMAGE vprofile-project/target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war + +EXPOSE 8080 +CMD ["catalina.sh", "run"] \ No newline at end of file diff --git a/Docker-files/d.txt b/Docker-files/d.txt new file mode 100755 index 000000000..e69de29bb diff --git a/Docker-files/db/Dockerfile b/Docker-files/db/Dockerfile new file mode 100755 index 000000000..c22363860 --- /dev/null +++ b/Docker-files/db/Dockerfile @@ -0,0 +1,8 @@ +FROM mysql:8.0.33 +LABEL "Project"="Vprofile" +LABEL "Author"="Aboelkhair93" + +ENV MYSQL_ROOT_PASSWORD="vprodbpass" +ENV MYSQL_DATABASE="accounts" + +ADD db_backup.sql docker-entrypoint-initdb.d/db_backup.sql diff --git a/Docker-files/db/db_backup.sql b/Docker-files/db/db_backup.sql new file mode 100755 index 000000000..bdb779d23 --- /dev/null +++ b/Docker-files/db/db_backup.sql @@ -0,0 +1,121 @@ +-- MySQL dump 10.13 Distrib 5.7.18, for Linux (x86_64) +-- +-- Host: localhost Database: accounts +-- ------------------------------------------------------ +-- Server version 5.7.18-0ubuntu0.16.10.1 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `role` +-- + +DROP TABLE IF EXISTS `role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `role` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `role` +-- + +LOCK TABLES `role` WRITE; +/*!40000 ALTER TABLE `role` DISABLE KEYS */; +INSERT INTO `role` VALUES (1,'ROLE_USER'); +/*!40000 ALTER TABLE `role` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user` +-- + +DROP TABLE IF EXISTS `user`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(255) DEFAULT NULL, + `userEmail` varchar(255) DEFAULT NULL, + `profileImg` varchar(255) DEFAULT NULL, + `profileImgPath` varchar(255) DEFAULT NULL, + `dateOfBirth` varchar(255) DEFAULT NULL, + `fatherName` varchar(255) DEFAULT NULL, + `motherName` varchar(255) DEFAULT NULL, + `gender` varchar(255) DEFAULT NULL, + `maritalStatus` varchar(255) DEFAULT NULL, + `permanentAddress` varchar(255) DEFAULT NULL, + `tempAddress` varchar(255) DEFAULT NULL, + `primaryOccupation` varchar(255) DEFAULT NULL, + `secondaryOccupation` varchar(255) DEFAULT NULL, + `skills` varchar(255) DEFAULT NULL, + `phoneNumber` varchar(255) DEFAULT NULL, + `secondaryPhoneNumber` varchar(255) DEFAULT NULL, + `nationality` varchar(255) DEFAULT NULL, + `language` varchar(255) DEFAULT NULL, + `workingExperience` varchar(255) DEFAULT NULL, + `password` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user` +-- + +LOCK TABLES `user` WRITE; +/*!40000 ALTER TABLE `user` DISABLE KEYS */; +INSERT INTO `user` VALUES (7,'admin_vp','admin@visualpathit.com',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'$2a$11$0a7VdTr4rfCQqtsvpng6GuJnzUmQ7gZiHXgzGPgm5hkRa3avXgBLK'),(8,'WahidKhan','wahid.khan74@gmail.com',NULL,NULL,'28/03/1994','M Khan','R Khan','male','unMarried','Ameerpet,Hyderabad','Ameerpet,Hyderabad','Software Engineer','Software Engineer','Java HTML CSS ','8888888888','8888888888','Indian','english','2 ','$2a$11$UgG9TkHcgl02LxlqxRHYhOf7Xv4CxFmFEgS0FpUdk42OeslI.6JAW'),(9,'Gayatri','gayatri@gmail.com',NULL,NULL,'20/06/1993','K','L','male','unMarried','Ameerpet,Hyderabad','Ameerpet,Hyderabad','Software Engineer','Software Engineer','Java HTML CSS ','9999999999','9999999999','India','english','5','$2a$11$gwvsvUrFU.YirMM1Yb7NweFudLUM91AzH5BDFnhkNzfzpjG.FplYO'),(10,'WahidKhan2','wahid.khan741@gmail.com',NULL,NULL,'28/03/1994','M Khan','R Khan','male','unMarried','Ameerpet,Hyderabad','Ameerpet,Hyderabad','Software Engineer','Software Engineer','Java HTML CSS ','7777777777','777777777','India','english','7','$2a$11$6oZEgfGGQAH23EaXLVZ2WOSKxcEJFnBSw2N2aghab0s2kcxSQwjhC'),(11,'KiranKumar','kiran@gmail.com',NULL,NULL,'8/12/1993','K K','RK','male','unMarried','California','James Street','Software Engineer','Software Engineer','Java HTML CSS ','1010101010','1010101010','India','english','10','$2a$11$EXwpna1MlFFlKW5ut1iVi.AoeIulkPPmcOHFO8pOoQt1IYU9COU0m'),(12,'Saikumar','sai@gmail.com',NULL,NULL,'20/06/1993','Sai RK','Sai AK','male','unMarried','California','US','Software Engineer','Software Engineer','Java HTML CSS AWS','8888888111','8888888111','India','english','8','$2a$11$pzWNzzR.HUkHzz2zhAgqOeCl0WaTgY33NxxJ7n0l.rnEqjB9JO7vy'),(13,'RamSai','ram@gmail.com',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'$2a$11$6BSmYPrT8I8b9yHmx.uTRu/QxnQM2vhZYQa8mR33aReWA4WFihyGK'); +/*!40000 ALTER TABLE `user` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user_role` +-- + +DROP TABLE IF EXISTS `user_role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user_role` ( + `user_id` int(11) NOT NULL, + `role_id` int(11) NOT NULL, + PRIMARY KEY (`user_id`,`role_id`), + KEY `fk_user_role_roleid_idx` (`role_id`), + CONSTRAINT `fk_user_role_roleid` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_user_role_userid` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user_role` +-- + +LOCK TABLES `user_role` WRITE; +/*!40000 ALTER TABLE `user_role` DISABLE KEYS */; +INSERT INTO `user_role` VALUES (4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1); +/*!40000 ALTER TABLE `user_role` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2017-12-07 16:32:31 diff --git a/Docker-files/web/Dockerfile b/Docker-files/web/Dockerfile new file mode 100755 index 000000000..c52ff6ab4 --- /dev/null +++ b/Docker-files/web/Dockerfile @@ -0,0 +1,6 @@ +FROM nginx +LABEL "Project"="Vprofile" +LABEL "Author"="Aboelkhair93" + +RUN rm -rf /etc/nginx/conf.d/default.conf +COPY nginvproapp.conf /etc/nginx/conf.d/vproapp.conf \ No newline at end of file diff --git a/Docker-files/web/nginvproapp.conf b/Docker-files/web/nginvproapp.conf new file mode 100755 index 000000000..ab3a503e4 --- /dev/null +++ b/Docker-files/web/nginvproapp.conf @@ -0,0 +1,9 @@ +upstream vproapp { + server vproapp:8080; +} +server { + listen 80; +location / { + proxy_pass http://vproapp; +} +} \ No newline at end of file diff --git a/README.md b/README.md index 88fd3cbba..37216c00d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Prerequisites -# +### - JDK 11 - Maven 3 - MySQL 8 diff --git a/aws-files/build_buildspec.yml b/aws-files/build_buildspec.yml new file mode 100644 index 000000000..424388c07 --- /dev/null +++ b/aws-files/build_buildspec.yml @@ -0,0 +1,25 @@ +version: 0.2 +#env: + #parameter-store: + #CODEARTIFACT_AUTH_TOKEN: CODEARTIFACT_AUTH_TOKEN +phases: + install: + runtime-versions: + java: corretto11 + commands: + - cp ./settings.xml /root/.m2/settings.xml + - export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain ArtifactDomain --domain-owner ID --region REGION --query authorizationToken --output text` + pre_build: + commands: + - apt-get update + - apt-get install -y jq + - wget https://dlcdn.apache.org/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz + - tar xzvf apache-maven-3.9.4-bin.tar.gz + - ln -s apache-maven-3.9.4 maven + build: + commands: + - mvn clean install -DskipTests +artifacts: + files: + - target/**/*.war + discard-paths: yes diff --git a/aws-files/sonar_buildspec.yml b/aws-files/sonar_buildspec.yml new file mode 100644 index 000000000..d033e2191 --- /dev/null +++ b/aws-files/sonar_buildspec.yml @@ -0,0 +1,37 @@ +version: 0.2 +env: + parameter-store: + LOGIN: LOGIN + HOST: HOST + Organization: Organization + Project: Project + #CODEARTIFACT_AUTH_TOKEN: CODEARTIFACT_AUTH_TOKEN +phases: + install: + runtime-versions: + java: corretto11 + commands: + - cp ./settings.xml /root/.m2/settings.xml + - export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain ArtifactDomain --domain-owner ID --region REGION --query authorizationToken --output text` + pre_build: + commands: + - apt-get update + - apt-get install -y jq checkstyle + - wget https://dlcdn.apache.org/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz + - tar xzvf apache-maven-3.9.4-bin.tar.gz + - ln -s apache-maven-3.9.4 maven + - wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip + - unzip ./sonar-scanner-cli-3.3.0.1492-linux.zip + - export PATH=$PATH:/sonar-scanner-3.3.0.1492-linux/bin/ + build: + commands: + - mvn test + - mvn checkstyle:checkstyle + - echo "Installing JDK11 as its a dependency for sonarqube code analysis" + - apt-get install -y openjdk-11-jdk + - export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 + - mvn sonar:sonar -Dsonar.login=$LOGIN -Dsonar.host.url=$HOST -Dsonar.projectKey=$Project -Dsonar.organization=$Organization -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ -Dsonar.junit.reportsPath=target/surefire-reports/ -Dsonar.jacoco.reportsPath=target/jacoco.exec -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml + - sleep 5 + - curl https://sonarcloud.io/api/qualitygates/project_status?projectKey=$Project >result.json + - cat result.json + - if [ $(jq -r '.projectStatus.status' result.json) = ERROR ] ; then $CODEBUILD_BUILD_SUCCEEDING -eq 0 ;fi diff --git a/aws-files/ssh_config_file b/aws-files/ssh_config_file new file mode 100644 index 000000000..02fa3733f --- /dev/null +++ b/aws-files/ssh_config_file @@ -0,0 +1,4 @@ +Host git-codecommit.*.amazonaws.com + User APKAXIXFJTQEW2ZCTWED + IdentityFile ~/.ssh/vpro-codecommit_rsa + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 000000000..84ea89113 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,49 @@ +version: '3.9' +services: + vprodb: + build: + context: ./Docker-files/db + image: aboelkhair93/vprofiledb + container_name: vprodb + ports: + - "3306:3306" + volumes: + - vprodbdata:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD=vprodbpass + + vprocache01: + image: memcached + ports: + - "11211:11211" + + vpromq01: + image: rabbitmq + ports: + - "15672:15672" + environment: + - RABBITMQ_DEFAULT_USER=guest + - RABBITMQ_DEFAULT_PASS=guest + + vproapp: + build: + context: ./Docker-files/app + image: aboelkhair93/vprofileapp + container_name: vproapp + ports: + - "8080:8080" + volumes: + - vproappdata:/usr/local/tomcat/webapps + + vproweb: + build: + context: ./Docker-files/web + image: aboelkhair93/vprofileweb + container_name: vproweb + ports: + - "80:80" + +volumes: + vprodbdata: {} + vproappdata: {} + \ No newline at end of file