diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..e08d8e4fe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM tomcat:8 +COPY target/*.war /usr/local/tomcat/webapps/addressbook.war diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..e07732a67 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,54 @@ +pipeline { + agent any + + tools { + maven 'M2_HOME' + terraform 'Terraform-1.3.7' + } + environment { + AWS_ACCESS_KEY_ID = '${Access_Key}' + AWS_SECRET_KEY = '${Secret_Key}' + } + + stages { + stage('Checkout') { + steps { + checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/devopscbabu/DevOpsAddressBook.git']]]) + } + } + stage('Compile') { + steps { + sh 'mvn clean package' + } + } + stage('Docker Build') { + steps { + sh 'docker build -t cbabu85/devopsaddressbook .' + } + } + stage('Docker Push') { + steps { + withCredentials([string(credentialsId: 'docker-hub', variable: 'dockerHubPwd')]) { + sh 'docker login -u cbabu85 -p ${dockerHubPwd}' + } + sh 'docker push cbabu85/devopsaddressbook' + } + } + stage('Terraform init') { + steps { + sh 'terraform init' + } + } + stage('Terraform Apply') { + steps { + sh 'terraform apply --auto-approve' + sleep 20 + } + } + stage('Docker Deploy using Ansible') { + steps { + ansiblePlaybook credentialsId: 'terraform-docker', disableHostKeyChecking: true, installation: 'ansible', inventory: 'dev.inv', playbook: 'deploy-docker.yml' + } + } + } +} diff --git a/babu b/babu new file mode 100644 index 000000000..401435cd6 --- /dev/null +++ b/babu @@ -0,0 +1 @@ +Welcome to my Class diff --git a/create-instance.tf b/create-instance.tf new file mode 100644 index 000000000..dffc538a3 --- /dev/null +++ b/create-instance.tf @@ -0,0 +1,10 @@ +resource "aws_instance" "MyInstance" { + ami = "ami-0f69bc5520884278e" + instance_type = "t2.micro" + key_name = "Mypemfile" + security_groups = ["sg-0ffb58db1648fe3a1"] + + tags = { + Name = "Terraform_Docker" + } +} diff --git a/deploy-docker.yml b/deploy-docker.yml new file mode 100644 index 000000000..21ac6bc20 --- /dev/null +++ b/deploy-docker.yml @@ -0,0 +1,35 @@ +--- +- hosts: dev + become: True + tasks: + - name: install python pip + apt: + name: python-pip + state: present + + - name: Install docker with python module + pip: + name: docker-py + state: present + + - name: Install docker + apt: + name: docker + state: present + + - name: start docker + service: + name: docker + state: started + enabled: yes + + - name: docker run user + shell: usermod -a -G docker ubuntu + + - name: Start the container + docker_container: + name: project-app + image: "cbabu85/addressbook" + state: started + published_ports: + - 0.0.0.0:8090:8090 diff --git a/dev.inv b/dev.inv new file mode 100644 index 000000000..1211a62fd --- /dev/null +++ b/dev.inv @@ -0,0 +1,2 @@ +[dev] +172.31.11.176 ansible_user=ubuntu diff --git a/file1.txt b/file1.txt new file mode 100644 index 000000000..68d54f7c9 --- /dev/null +++ b/file1.txt @@ -0,0 +1,7 @@ +hi +hfdjdk +Hello msater +fhdkcksdksnn +bfbfbhf +l;'kl;kl.l +tyjytj diff --git a/pom.xml b/pom.xml index f2b7c1429..43d466a99 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ false 8.0.0.alpha2 ${vaadin.version} + @@ -55,7 +56,8 @@ - + + com.vaadin vaadin-compatibility-server ${vaadin.version} @@ -65,6 +67,7 @@ vaadin-compatibility-shared ${vaadin.version} + com.vaadin vaadin-compatibility-client-compiled @@ -162,12 +165,17 @@ org.apache.maven.plugins maven-compiler-plugin - 3.2 + 3.8.1 1.8 1.8 + + org.apache.maven.plugins + maven-war-plugin + 3.3.1 + org.eclipse.jetty jetty-maven-plugin @@ -195,7 +203,7 @@ addressbook - + @@ -204,10 +212,10 @@ maven-surefire-report-plugin 2.19.1 + - - + development @@ -251,6 +259,8 @@ 2 + + @@ -330,15 +340,17 @@ true + maven-javadoc-plugin 2.9.1 @@ -417,17 +429,19 @@ + org.apache.maven.plugins maven-pmd-plugin @@ -453,16 +467,18 @@ addressbook-build/checkstyle.xml + + maven-javadoc-plugin 2.7 diff --git a/provider.tf b/provider.tf new file mode 100644 index 000000000..2659fb586 --- /dev/null +++ b/provider.tf @@ -0,0 +1,5 @@ +provider "aws" { + region = "ap-south-1" + access_key = "AKIARSATK$CBXE42KNO7Z" + secret_key = "SoJ+9fN+tnwqp$/RvKNHgYp1fguPj+PfdwmaRvnuN" +} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..b5b16b80a --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,30 @@ +# must be unique in a given SonarQube instance +#sonar.projectKey=sonaranalysiskey +#sonar.projectKey=Sonarqubescan +sonar.projectKey=sonarscan +#sonar.projectKey=mavenjavaproject +#sonar.organization=devopscbabu +sonar.host.url=http://13.232.193.103:9000 +sonar.login=ec5e3ffb98dce31af2b2a25c0399040a455ee0f3 + +# --- optional properties --- + +# defaults to project key +#sonar.projectName=maven-sonarscanner +# defaults to 'not provided' +#sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Defaults to . +sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 +#sonar.sources=src/main/java + +# Language +sonar.language=java + +# Comma-separated paths to directories containing the compiled bytecode files corresponding to your source files +sonar.java.binaries=. +#sonar.sources=. +#sonar.java.binaries=**/target/classes