mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-01-05 10:01:13 +00:00
Merge 9b262d3511 into cefaf55dd1
This commit is contained in:
commit
6723523143
3 changed files with 68 additions and 1 deletions
20
Dockerfile
Normal file
20
Dockerfile
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
FROM eclipse-temurin:21-jdk-alpine AS builder
|
||||
|
||||
WORKDIR /source
|
||||
|
||||
COPY gradlew .
|
||||
COPY build.gradle .
|
||||
COPY settings.gradle .
|
||||
COPY gradle ./gradle
|
||||
RUN chmod 500 gradlew
|
||||
|
||||
RUN ./gradlew dependencies --info --no-daemon
|
||||
|
||||
COPY . .
|
||||
RUN ./gradlew build --no-daemon -x test
|
||||
|
||||
FROM eclipse-temurin:21-jre-alpine
|
||||
WORKDIR /app
|
||||
COPY --from=builder /source/build/libs/*.jar app.jar
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
||||
47
Jenkinsfile
vendored
Normal file
47
Jenkinsfile
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
GIT_COMMIT_SHORT = sh(script: "git rev-parse --short HEAD", returnStdout: true).trim()
|
||||
DOCKER_HUB_USER = "m1kky8"
|
||||
DOCKRHUB_CREDS = "580b959d-d40a-422f-a3d7-cf11b2ec7a4c"
|
||||
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('checkStyle') {
|
||||
when { not {branch 'main' }}
|
||||
steps {
|
||||
sh './gradlew checkstyleMain'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Test') {
|
||||
when { not {branch 'main' }}
|
||||
steps {
|
||||
sh './gradlew test'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
script {
|
||||
def branch = env.BRANCH_NAME
|
||||
def dockerRepo = (branch == 'main') ? 'main' : 'mr'
|
||||
def imageTag = "${DOCKER_HUB_USER}/${dockerRepo}:${GIT_COMMIT_SHORT}"
|
||||
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: DOCKERHUB_CREDS,
|
||||
usernameVariable: 'DOCKER_USER',
|
||||
passwordVariable: 'DOCKER_PASS'
|
||||
)]) {
|
||||
echo "Logging in to Docker Hub..."
|
||||
sh "echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin"
|
||||
echo "Pushing Docker image to ${imageTag}"
|
||||
sh "docker push ${imageTag}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
rootProject.name = 'spring-petclinic'
|
||||
rootProject.name = 'my-petclinic'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue