Skip to content
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
20 changes: 8 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# Stage 1: Build the application
FROM maven:3.8.1-openjdk-17-slim AS build
FROM maven:3.9.6-eclipse-temurin-17 AS BUILD
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn clean package -DskipTests
COPY . .
RUN mvn package -DskipTests

FROM build as test
CMD mvn clean test

FROM openjdk:17-jdk-alpine
WORKDIR /app
COPY --from=build /app/target/sysfoo-0.0.1-SNAPSHOT.jar ./sysfoo.jar
FROM eclipse-temurin:22-jre-alpine
WORKDIR /run
COPY --from=BUILD /app/target/sysfoo*.jar sysfoo.jar
EXPOSE 8080
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "sysfoo.jar"]

CMD java -jar /run/sysfoo.jar
12 changes: 12 additions & 0 deletions Dockerfile_singlestage
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM maven:3.9.6-eclipse-temurin-17

WORKDIR /build

COPY . .

RUN mvn package -DskipTests && \
mv target/sysfoo*.jar /run/sysfoo.jar

EXPOSE 8080

CMD java -jar /run/sysfoo.jar
15 changes: 15 additions & 0 deletions Dockerfile_tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Stage 1: Build the application
FROM maven:3.8.1-openjdk-17-slim AS build
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn clean package -DskipTests

FROM build as test
CMD mvn clean test

FROM openjdk:17-jdk-alpine
WORKDIR /app
COPY --from=build /app/target/sysfoo-0.0.1-SNAPSHOT.jar ./sysfoo.jar
EXPOSE 8080
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "sysfoo.jar"]
80 changes: 80 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
pipeline {
agent any
stages {
stage('build') {
agent {
docker {
image 'maven:3.9.6-eclipse-temurin-17'
}

}
steps {
echo 'compiling sysfoo app...'
sh 'mvn compile'
}
}

stage('test') {
agent {
docker {
image 'maven:3.9.6-eclipse-temurin-17'
}

}
steps {
echo 'running unit tests...'
sh 'mvn clean test'
}
}

stage('package') {
parallel {
stage('package') {
agent {
docker {
image 'maven:3.9.6-eclipse-temurin-17'
}

}
steps {
echo 'packaging the app...'
sh '''#Truncate the GIT_COMIT to the first 7 characters
GIT_SHORT_COMMIT=$(echo $GIT_COMMIT | cut -c 1-7)

# Set the version using Maven
mvn versions:set -DnewVersion="$GIT_SHORT_COMMIT"
mvn versions:commit'''
sh 'mvn package -DskipTests'
archiveArtifacts '**/target/*.jar'
}
}

stage('Docker B&P') {
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') {
def commitHash = env.GIT_COMMIT.take(7)
def dockerImage = docker.build("jmpires/sysfoo:${commitHash}", "./")
dockerImage.push()
dockerImage.push("latest")
dockerImage.push("dev")
}
}

}
}

}
}

}
tools {
maven 'Maven 3.9.6'
}
post {
always {
echo 'This pipeline is completed..'
}

}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Sysfoo Application

A Devops Learning App
A Devops Learning App useful for CI Implementation

## About the Application

Expand Down
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CH01
CH02
2 changes: 2 additions & 0 deletions myTrigger.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
first pull trigger
second try ...