mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 20:35:49 +00:00
Merge d8f2bdb1a1
into 2aa53f929d
This commit is contained in:
commit
154c34a4d7
7 changed files with 228 additions and 62 deletions
31
.github/workflows/gradle-build.yml
vendored
31
.github/workflows/gradle-build.yml
vendored
|
@ -1,31 +0,0 @@
|
|||
# This workflow will build a Java project with Gradle, and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-gradle
|
||||
|
||||
name: Java CI with Gradle
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: [ '17' ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK ${{matrix.java}}
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: ${{matrix.java}}
|
||||
distribution: 'adopt'
|
||||
cache: maven
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
85
.github/workflows/main.yml
vendored
Normal file
85
.github/workflows/main.yml
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
name: CI Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
checkstyle:
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: maven:3.8.5-openjdk-17
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run Checkstyle
|
||||
run: mvn checkstyle:checkstyle
|
||||
- name: Upload Checkstyle Report
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: checkstyle-result
|
||||
path: target/checkstyle-result.xml
|
||||
|
||||
test:
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: maven:3.8.5-openjdk-17
|
||||
needs: checkstyle
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run Tests
|
||||
run: mvn test -Dmaven.test.failure.ignore=true
|
||||
|
||||
build:
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: maven:3.8.5-openjdk-17
|
||||
needs: test
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build Package
|
||||
run: mvn clean package -DskipTests
|
||||
- name: Upload JAR Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: jar-files
|
||||
path: target/*.jar
|
||||
|
||||
build_image:
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: self-hosted
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to Registry (mr)
|
||||
run: docker login mr:8084 -u ${{ vars.REGISTRY_USER }} -p ${{ vars.REGISTRY_PASS }}
|
||||
- name: Extract Short SHA
|
||||
id: vars
|
||||
run: echo "::set-output name=short_sha::$(echo $GITHUB_SHA | cut -c1-7)"
|
||||
- name: Build Docker Image (mr)
|
||||
run: docker build -t mr:8084/spring-petclinic:${{ steps.vars.outputs.short_sha }} .
|
||||
- name: Push Docker Image (mr)
|
||||
run: docker push mr:8084/spring-petclinic:${{ steps.vars.outputs.short_sha }}
|
||||
|
||||
build_image_main:
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to Registry (main)
|
||||
run: docker login main:8083 -u ${{ vars.REGISTRY_USER }} -p ${{ vars.REGISTRY_PASS }}
|
||||
- name: Extract Short SHA
|
||||
id: vars
|
||||
run: echo "::set-output name=short_sha::$(echo $GITHUB_SHA | cut -c1-7)"
|
||||
- name: Build Docker Image (main)
|
||||
run: docker build -t main:8083/spring-petclinic:${{ steps.vars.outputs.short_sha }} .
|
||||
- name: Push Docker Image (main)
|
||||
run: docker push main:8083/spring-petclinic:${{ steps.vars.outputs.short_sha }}
|
29
.github/workflows/maven-build.yml
vendored
29
.github/workflows/maven-build.yml
vendored
|
@ -1,29 +0,0 @@
|
|||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven
|
||||
|
||||
name: Java CI with Maven
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: [ '17' ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK ${{matrix.java}}
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: ${{matrix.java}}
|
||||
distribution: 'adopt'
|
||||
cache: maven
|
||||
- name: Build with Maven Wrapper
|
||||
run: ./mvnw -B verify
|
32
Dockerfile
Normal file
32
Dockerfile
Normal file
|
@ -0,0 +1,32 @@
|
|||
FROM maven AS build
|
||||
WORKDIR /app
|
||||
COPY pom.xml .
|
||||
COPY src ./src
|
||||
RUN mvn clean package -DskipTests
|
||||
|
||||
RUN jar xf /app/target/spring-petclinic-3.4.0-SNAPSHOT.jar
|
||||
RUN jdeps \
|
||||
--ignore-missing-deps \
|
||||
--print-module-deps \
|
||||
--multi-release 17 \
|
||||
--recursive \
|
||||
--class-path 'BOOT-INF/lib/*' \
|
||||
/app/target/spring-petclinic-3.4.0-SNAPSHOT.jar > modules.txt
|
||||
|
||||
RUN $JAVA_HOME/bin/jlink \
|
||||
--add-modules $(cat modules.txt) \
|
||||
--strip-debug \
|
||||
--no-man-pages \
|
||||
--no-header-files \
|
||||
--compress=2 \
|
||||
--output /javaruntime
|
||||
|
||||
FROM debian:buster-slim
|
||||
ENV JAVA_HOME=/opt/java/openjdk
|
||||
ENV PATH="${JAVA_HOME}/bin:${PATH}"
|
||||
COPY --from=build /javaruntime $JAVA_HOME
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/target/spring-petclinic-3.4.0-SNAPSHOT.jar .
|
||||
CMD ["java", "-Dspring.profiles.active=postgres", "-jar", "spring-petclinic-3.4.0-SNAPSHOT.jar"]
|
||||
|
94
Jenkinsfile
vendored
Normal file
94
Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
pipeline {
|
||||
agent none
|
||||
|
||||
stages {
|
||||
stage('Checkstyle') {
|
||||
when {
|
||||
changeRequest()
|
||||
}
|
||||
agent {
|
||||
docker { image 'maven:3.8.5-openjdk-17' }
|
||||
}
|
||||
steps {
|
||||
checkout scm
|
||||
sh 'mvn checkstyle:checkstyle'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
archiveArtifacts artifacts: 'target/checkstyle-result.xml', allowEmptyArchive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
when {
|
||||
changeRequest()
|
||||
}
|
||||
|
||||
agent {
|
||||
docker { image 'maven:3.8.5-openjdk-17' }
|
||||
}
|
||||
steps {
|
||||
sh 'mvn test -Dcheckstyle.skip=true'
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
when {
|
||||
changeRequest()
|
||||
}
|
||||
|
||||
agent {
|
||||
docker { image 'maven:3.8.5-openjdk-17' }
|
||||
}
|
||||
steps {
|
||||
sh 'mvn clean package -DskipTests -Dcheckstyle.skip=true'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
archiveArtifacts artifacts: 'target/*.jar', allowEmptyArchive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build Image') {
|
||||
when {
|
||||
changeRequest()
|
||||
}
|
||||
|
||||
agent {
|
||||
docker {
|
||||
image 'docker:20.10.16'
|
||||
args '--privileged -u root -v /var/run/docker.sock:/var/run/docker.sock'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
def docker_image=docker.build("mr:8084/spring-petclinic:$GIT_COMMIT")
|
||||
sh 'docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASS" mr:8084'
|
||||
docker.withRegistry('http://mr:8084') {
|
||||
docker_image.push()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build Image Main') {
|
||||
when {
|
||||
not { changeRequest() }
|
||||
}
|
||||
|
||||
agent {
|
||||
docker {
|
||||
image 'docker:20.10.16'
|
||||
args '--privileged -u root -v /var/run/docker.sock:/var/run/docker.sock'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
def docker_image=docker.build("main:8083/spring-petclinic:$GIT_COMMIT")
|
||||
sh 'docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASS" main:8083'
|
||||
docker.withRegistry('http://main:8083') {
|
||||
docker_image.push()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
# Spring PetClinic Sample Application [](https://github.com/spring-projects/spring-petclinic/actions/workflows/maven-build.yml)[](https://github.com/spring-projects/spring-petclinic/actions/workflows/gradle-build.yml)
|
||||
|
||||
|
||||
[](https://gitpod.io/#https://github.com/spring-projects/spring-petclinic) [](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=7517918)
|
||||
|
||||
## Understanding the Spring Petclinic application with a few diagrams
|
||||
|
||||
## TESTMESSAGE asdasdasda
|
||||
|
||||
[See the presentation here](https://speakerdeck.com/michaelisvy/spring-petclinic-sample-application)
|
||||
|
||||
## Run Petclinic locally
|
||||
|
|
16
pom.xml
16
pom.xml
|
@ -169,8 +169,8 @@
|
|||
<rules>
|
||||
<requireJavaVersion>
|
||||
<message>This build requires at least Java ${java.version},
|
||||
update your JVM, and
|
||||
run the build again</message>
|
||||
update your JVM, and
|
||||
run the build again</message>
|
||||
<version>${java.version}</version>
|
||||
</requireJavaVersion>
|
||||
</rules>
|
||||
|
@ -222,6 +222,18 @@
|
|||
<propertyExpansion>config_loc=${basedir}/src/checkstyle/</propertyExpansion>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>generate-checkstyle-report</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>checkstyle</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<configLocation>src/checkstyle/nohttp-checkstyle.xml</configLocation>
|
||||
<outputFile>target/site/checkstyle.html</outputFile>
|
||||
<outputFileFormat>plain</outputFileFormat>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
Loading…
Reference in a new issue