Skip to content
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

Adding multi-stage Docker file #130

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM maven:3.6.3-jdk-11-slim as build
WORKDIR /opt/demo
COPY . /opt/demo
RUN mvn package -D skipTests

FROM tomcat as run
WORKDIR /usr/local/tomcat
COPY --from=build /opt/demo/target/sysfoo.war webapps/ROOT.war

68 changes: 68 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
pipeline {
agent none
stages {
stage('Build') {
agent {
docker {
image 'maven:3.6.3-jdk-11-slim'
}

}
steps {
sh 'mvn compile'
}
}

stage('Test') {
agent {
docker {
image 'maven:3.6.3-jdk-11-slim'
}

}
steps {
sh 'mvn clean test'
}
}

stage('Package') {
when {
branch 'master'
}
parallel {
stage('Package') {
agent {
docker {
image 'maven:3.6.3-jdk-11-slim'
}

}
steps {
sh 'mvn package -DskipTests'
archiveArtifacts 'target/*.war'
}
}

stage('DockerBnP') {
agent any
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') {
def dockerImage = docker.build("paragsin/sysfoo:v${env.BUILD_ID}", "./")
dockerImage.push()
dockerImage.push("latest")
dockerImage.push("dev")
}
}

}
}

}
}

}
triggers {
pollSCM('H/2 * * * *')
}
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
This is a Sample Maven App.

Test 01: Adding Test line.
Test 02: Add test line, and create pull request to protected master.
1 change: 1 addition & 0 deletions src/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adding text file