mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 23:05:49 +00:00
ahhhh
This commit is contained in:
parent
d2b23badf3
commit
d6a0b57127
2 changed files with 7 additions and 22 deletions
19
Dockerfile
19
Dockerfile
|
@ -1,24 +1,11 @@
|
||||||
# Use an official OpenJDK runtime as a parent image
|
# Use an official OpenJDK runtime as a parent image
|
||||||
FROM openjdk
|
FROM openjdk:11-jdk-slim
|
||||||
|
|
||||||
# Set the working directory inside the container
|
# Set the working directory inside the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the Maven wrapper and the pom.xml file
|
# Copy the JAR file to the app directory (adjust this path according to your actual JAR file name in the target directory)
|
||||||
COPY .mvn/ .mvn
|
COPY target/*.jar app.jar
|
||||||
COPY mvnw pom.xml ./
|
|
||||||
|
|
||||||
# Copy the project source code
|
|
||||||
COPY src ./src
|
|
||||||
|
|
||||||
# Use an argument to force a rebuild
|
|
||||||
ARG FORCE_REBUILD=unknown
|
|
||||||
|
|
||||||
# Package the application
|
|
||||||
RUN ./mvnw clean package -Dmaven.test.skip=true && ls -alh /app/target/
|
|
||||||
|
|
||||||
# Move the JAR file to the app directory (update this if necessary based on actual JAR names)
|
|
||||||
COPY target/*.jar /app/app.jar
|
|
||||||
|
|
||||||
# Run the jar file
|
# Run the jar file
|
||||||
CMD ["java", "-jar", "app.jar"]
|
CMD ["java", "-jar", "app.jar"]
|
||||||
|
|
10
Jenkinsfile
vendored
10
Jenkinsfile
vendored
|
@ -17,11 +17,11 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Prepare Environment') {
|
stage('Build JAR') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
sh "pwd" // Prints the current working directory
|
echo "Building JAR..."
|
||||||
sh "ls -alh" // Lists all files in the current directory
|
sh './mvnw clean package -Dmaven.test.skip=true'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,7 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "Building Docker Image..."
|
echo "Building Docker Image..."
|
||||||
// Correctly escape dollar signs in Groovy string
|
def dockerImage = docker.build("spring-petclinic", "--no-cache .")
|
||||||
def dockerImage = docker.build("spring-petclinic", "--no-cache --build-arg FORCE_REBUILD=$(date +%s) .")
|
|
||||||
echo "Docker Image built: ${dockerImage.id}"
|
echo "Docker Image built: ${dockerImage.id}"
|
||||||
// Store the Docker image ID in the environment if needed across stages
|
// Store the Docker image ID in the environment if needed across stages
|
||||||
env.DOCKER_IMAGE_ID = dockerImage.id
|
env.DOCKER_IMAGE_ID = dockerImage.id
|
||||||
|
@ -40,7 +39,6 @@ pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Further stages would reference env.DOCKER_IMAGE_ID if needed
|
// Further stages would reference env.DOCKER_IMAGE_ID if needed
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
|
|
Loading…
Reference in a new issue