Skip to content

Backuping files #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 99 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
e3d1484
Update pom.xml
sudipto92 Mar 5, 2020
4a8ca49
Creating docker-compose.yml
sudipto92 Mar 5, 2020
532e166
Update Dockerfile
sudipto92 Mar 5, 2020
cb5c28f
Update Dockerfile
sudipto92 Mar 5, 2020
0341a87
Delete HelloController.java
sudipto92 Mar 6, 2020
6c9cab3
Create HelloController.java
sudipto92 Mar 6, 2020
427d1eb
Update HelloController.java
sudipto92 Mar 6, 2020
d21bb15
Update Dockerfile
sudipto92 Mar 6, 2020
a86c5f8
Update Dockerfile
sudipto92 Mar 6, 2020
f59e5f9
Update Dockerfile
sudipto92 Mar 6, 2020
3e4c185
Update Dockerfile
sudipto92 Mar 6, 2020
2be4111
Update Dockerfile
sudipto92 Mar 6, 2020
b47fa85
Update Dockerfile
sudipto92 Mar 6, 2020
af018e5
Update Dockerfile
sudipto92 Mar 6, 2020
ef66269
Update Dockerfile
sudipto92 Mar 6, 2020
bb6d61b
Update Dockerfile
sudipto92 Mar 6, 2020
e03d076
Update Dockerfile
sudipto92 Mar 6, 2020
db2583d
Update Dockerfile
sudipto92 Mar 6, 2020
14c1913
Create site.yml
sudipto92 Mar 9, 2020
cb37185
Create key.pem
sudipto92 Mar 9, 2020
ec585e9
Add files via upload
sudipto92 Mar 9, 2020
72c3d36
Create main.yml
sudipto92 Mar 9, 2020
f5fe7f2
Update host
sudipto92 Mar 9, 2020
244bb1e
Update host
sudipto92 Mar 9, 2020
cee086c
Update host
sudipto92 Mar 9, 2020
dbd26df
Update Dockerfile
sudipto92 Mar 9, 2020
37be1f7
Update Dockerfile
sudipto92 Mar 9, 2020
d2006bc
Update host
sudipto92 Mar 9, 2020
5b5e701
Update host
sudipto92 Mar 9, 2020
294d2ec
Update host
sudipto92 Mar 9, 2020
32e515c
Update host
sudipto92 Mar 9, 2020
d3db62f
Delete key.pem
sudipto92 Mar 9, 2020
858a76a
Update main.yml
sudipto92 Mar 9, 2020
9fad77d
Update main.yml
sudipto92 Mar 9, 2020
5b6335b
Create site.yml
sudipto92 Mar 9, 2020
211a13e
Create host
sudipto92 Mar 9, 2020
b7e75f9
Create main.yml
sudipto92 Mar 9, 2020
59008e2
Update host
sudipto92 Mar 9, 2020
9dca088
Update Dockerfile
sudipto92 Mar 9, 2020
c1ca422
Update HelloController.java
sudipto92 Mar 9, 2020
bcd94fd
Update host
sudipto92 Mar 9, 2020
0dfaf4b
Update Dockerfile
sudipto92 Mar 11, 2020
744abff
Update Dockerfile
sudipto92 Mar 11, 2020
f470a64
Update Dockerfile
sudipto92 Mar 11, 2020
9985abf
Update Dockerfile
sudipto92 Mar 11, 2020
f98f3bf
Update HelloController.java
sudipto92 Mar 11, 2020
33ce14e
Update HelloController.java
sudipto92 Mar 11, 2020
870fb66
Update HelloController.java
sudipto92 Mar 11, 2020
03f5df9
Update host
sudipto92 Mar 11, 2020
4190dd0
Create deploy.sh
sudipto92 Mar 11, 2020
aec8c79
Update main.yml
sudipto92 Mar 11, 2020
f789633
Update HelloController.java
sudipto92 Mar 11, 2020
7ae9c24
Update HelloController.java
sudipto92 Mar 11, 2020
aed7594
Update docker-compose.yml
sudipto92 Mar 11, 2020
afc44d5
Update HelloController.java
sudipto92 Mar 11, 2020
d618caf
Create Jenkinsfile
sudipto92 Apr 8, 2020
a5f66ec
Update HelloController.java
sudipto92 Apr 8, 2020
d0fa53e
Update Jenkinsfile
sudipto92 Apr 8, 2020
1d3d8c4
Update Jenkinsfile
sudipto92 Apr 8, 2020
ada69de
Update Jenkinsfile
sudipto92 Jul 14, 2020
8e61fb8
Update Jenkinsfile
sudipto92 Jul 14, 2020
e967068
Update Jenkinsfile
sudipto92 Jul 14, 2020
ffe0f63
Update Jenkinsfile
sudipto92 Jul 14, 2020
97f8e0d
Update Jenkinsfile
sudipto92 Jul 14, 2020
69a6952
Update Jenkinsfile
sudipto92 Jul 14, 2020
64f318a
Update Jenkinsfile
sudipto92 Jul 15, 2020
3e258e7
Update Jenkinsfile
sudipto92 Jul 15, 2020
bb2cdfb
Update Jenkinsfile
sudipto92 Jul 15, 2020
1b983b6
Update Jenkinsfile
sudipto92 Jul 15, 2020
8fa84bd
Update Jenkinsfile
sudipto92 Jul 15, 2020
8867495
Update Jenkinsfile
sudipto92 Jul 15, 2020
782ac7c
Update Jenkinsfile
sudipto92 Jul 15, 2020
75cc1d2
Update Jenkinsfile
sudipto92 Jul 15, 2020
4344ea5
Update Jenkinsfile
sudipto92 Jul 15, 2020
caa3534
Update Jenkinsfile
sudipto92 Jul 15, 2020
12993ef
Update Jenkinsfile
sudipto92 Jul 15, 2020
fc72b24
Update Jenkinsfile
sudipto92 Jul 15, 2020
fffc808
Create deploy.yml
sudipto92 Jul 15, 2020
c84d40d
Create service.yml
sudipto92 Jul 15, 2020
5dd7803
Update main.yml
sudipto92 Jul 15, 2020
ce36dd2
Update deploy.sh
sudipto92 Jul 15, 2020
60ed6a9
Update site.yml
sudipto92 Jul 15, 2020
4a723b3
Update deploy.sh
sudipto92 Jul 15, 2020
71e686d
Update main.yml
sudipto92 Jul 15, 2020
f7f33e1
Update deploy.sh
sudipto92 Jul 15, 2020
d9313c5
Update deploy.sh
sudipto92 Jul 15, 2020
77345cb
Create run_deploy.sh
sudipto92 Jul 15, 2020
b6b472d
Update main.yml
sudipto92 Jul 15, 2020
8886f93
Update Jenkinsfile
sudipto92 Jul 15, 2020
1339965
Update HelloController.java
sudipto92 Jul 15, 2020
5a3c684
Update CicdAppliedToSpringBootJavaAppApplicationTests.java
sudipto92 Jul 15, 2020
ef3a9e0
Update Jenkinsfile
sudipto92 Jul 16, 2020
fa66fac
Update HelloController.java
sudipto92 Jul 16, 2020
0a79146
Update HelloController.java
sudipto92 Jul 16, 2020
c1a91a8
Update HelloController.java
sudipto92 Jul 16, 2020
d0b28cb
Update HelloController.java
sudipto92 Jul 16, 2020
28a4f55
Update service.yml
sudipto92 Jul 17, 2020
b9c3268
Update HelloController.java
sudipto92 Jul 17, 2020
0d8ee82
Update HelloController.java
sudipto92 Jul 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ VOLUME /tmp
EXPOSE 8080

# The application's jar file
ARG JAR_FILE
#ARG JAR_FILE

# Add the application's jar to the container
ADD ${JAR_FILE} app.jar
#ADD ${JAR_FILE} app.jar
COPY target/*.jar app.jar

#Adding HealthCheckup
HEALTHCHECK CMD curl --fail http://localhost:8080/ || exit 1

# Run the jar file
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]



45 changes: 45 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
node{
def Namespace = "default"
def ImageName = "sudiptod/cicd"
def Creds = "DockerHub"
def GITHUB_URL = "https://github.com/sudipto92/cicd-applied-to-spring-boot-java-app.git"
def GITHUB_Creds = "GITHUB_CREDENTIALS"
try{

stage('Checkout'){
git credentialsId: "${GITHUB_Creds}", url: "${GITHUB_URL}"
sh "git rev-parse --short HEAD > .git/commit-id"
imageTag= readFile('.git/commit-id').trim()
}
stage('Compile, Test and Coverage'){
sh "/usr/bin/mvn -B clean deploy"
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: "/var/lib/jenkins/workspace/${JOB_NAME}/target/site/jacoco/", reportFiles: 'index.html', reportName: 'Jacoco HTML Report', reportTitles: 'Jacoco'])
}

stage('SonarQube Analysis'){
withSonarQubeEnv('sonar') {
sh "/opt/sonar-scanner/bin/sonar-scanner -Dsonar.projectKey=${JOB_NAME} -Dsonar.projectName=${JOB_NAME} -Dsonar.projectVersion=${BUILD_NUMBER} -Dsonar.sources=. -Dsonar.java.binaries=target/ -Dsonar.issuesReport.html.enable=true -Dsonar.issuesReport.html.location=. -Dsonar.issuesReport.html.name=sample -Dsonar.login=admin -Dsonar.password=admin123"
}
}


stage('Docker Build, Push'){
withDockerRegistry([credentialsId: "${Creds}", url:'https://index.docker.io/v1/']) {
sh "docker build -t ${ImageName}:${imageTag} ."
sh "docker tag ${ImageName}:${imageTag} ${ImageName}:latest"
sh "docker push ${ImageName}:latest"
sh "docker push ${ImageName}:${imageTag}"
}
}

stage('Deploy'){
sh " curl -X POST https://admin:admin@172.31.75.85/api/v2/job_templates/23/launch/ --insecure"
}
}

catch (err) {
currentBuild.result = 'FAILURE'
}
}


4 changes: 4 additions & 0 deletions ansible/host
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[cloud]
#localhost ansible_connection=local
172.31.41.185 ansible_connection=ssh ansible_user=ubuntu ansible_ssh_private_key_file=/var/lib/jenkins/key.pem
#other2.example.com ansible_connection=ssh ansible_user=myotheruser
10 changes: 10 additions & 0 deletions ansible/roles/deploy/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: Update apt-get repo and cache
apt: update_cache=yes force_apt_get=yes cache_valid_time=3600

- name: This command will change the working directory
shell:
cmd: docker-compose up -d
chdir: /var/lib/jenkins/workspace/pipeline-maven-ansible-1



6 changes: 6 additions & 0 deletions ansible/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- hosts: cloud
become: yes
roles:
- deploy

4 changes: 4 additions & 0 deletions ansiblek8/host
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[cloud]
#localhost ansible_connection=local
172.31.44.14 ansible_connection=ssh ansible_user=k8s-admin ansible_password=qwerty
#other2.example.com ansible_connection=ssh ansible_user=myotheruser
22 changes: 22 additions & 0 deletions ansiblek8/roles/deploy/files/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#sudo scp /etc/kubernetes/admin.conf $HOME/
#sudo chown $(id -u):$(id -g) $HOME/admin.conf
#export KUBECONFIG=$HOME/admin.conf

whoami >/tmp/a.txt


kubectl get services | grep knote
RESULT=$?

if [ $RESULT -eq 0 ]; then
kubectl delete -f /tmp/deployment/deploy.yml
kubectl apply -f /tmp/deployment/deploy.yml
else
kubectl delete -f /tmp/deployment
kubectl apply -f /tmp/deployment/
fi




20 changes: 20 additions & 0 deletions ansiblek8/roles/deploy/files/deployment/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: knote
spec:
replicas: 1
selector:
matchLabels:
app: knote
template:
metadata:
labels:
app: knote
spec:
containers:
- name: app
image: sudiptod/cicd
ports:
- containerPort: 8080
imagePullPolicy: Always
12 changes: 12 additions & 0 deletions ansiblek8/roles/deploy/files/deployment/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: knote
spec:
selector:
app: knote
ports:
- port: 80
targetPort: 8080
nodePort: 30000
type: NodePort
3 changes: 3 additions & 0 deletions ansiblek8/roles/deploy/files/run_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

su admin "/tmp/deploy.sh"
11 changes: 11 additions & 0 deletions ansiblek8/roles/deploy/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: Transfer executable script script
copy: src=deploy.sh dest=/tmp mode=0777

- name: Transfer executable script script
copy: src=run_deploy.sh dest=/tmp mode=0777

- name: Transfer deployment script
copy: src=deployment dest=/tmp

- name: Execute the script
command: bash /tmp/run_deploy.sh
5 changes: 5 additions & 0 deletions ansiblek8/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: all
become: yes
roles:
- deploy
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "3"
services:
spring-boot-app:
image: sudiptod/cicd:latest
ports:
- 80:8080
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</plugin>

<!-- spotify's dockerfile-maven-plugin -->

<!--
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
Expand All @@ -87,7 +87,7 @@
</configuration>
</plugin>

<!-- maven-dependency-plugin useful for creating docker image -->
maven-dependency-plugin useful for creating docker image -->

<plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

@RestController
public class HelloController {

@GetMapping("/")
public String home() {
return "Hello World from DZONE";
}

@GetMapping("/")
public String home() {
return "Welcome To Nucleus";
}
@GetMapping("/sudo")
public String home1() {
return "Spring Boot Application Testing ";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CicdAppliedToSpringBootJavaAppApplicationTests {
@Test
public void contextLoads() {

Assert.assertEquals("Hello World from DZONE",helloController.home() );
Assert.assertEquals("Welcome To Nucleus",helloController.home() );
}


Expand Down