From 53ef24191b0f9ca01ca386a942c5895f01326e35 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 15:14:06 -0400 Subject: [PATCH] latest --- Dockerfile | 14 ++------------ Jenkinsfile | 4 +++- docker-compose_spring-petclinic.yml | 1 - 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2dbfce412..012bb41ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,10 @@ # Use an official OpenJDK runtime as a parent image -FROM openjdk +FROM openjdk:11 # Set the working directory inside the container WORKDIR /app -# Copy the Maven wrapper and the pom.xml file -COPY .mvn/ .mvn -COPY mvnw pom.xml ./ - -# Copy the project source code -COPY src ./src - -# Package the application -RUN ./mvnw clean package -DskipTests - -# Copy the JAR file to the app directory +# Copy the built JAR file from the build context COPY target/*.jar app.jar # Run the jar file diff --git a/Jenkinsfile b/Jenkinsfile index 31609f16c..5142de2f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,15 +21,17 @@ pipeline { steps { script { echo "Building Docker Image..." + // Ensure Maven build is executed + sh './mvnw clean package -DskipTests' def dockerImage = docker.build("spring-petclinic") echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages env.DOCKER_IMAGE_ID = dockerImage.id - sh 'ls -la target/' } } } + } post { diff --git a/docker-compose_spring-petclinic.yml b/docker-compose_spring-petclinic.yml index 81bd88661..4187c4fe8 100644 --- a/docker-compose_spring-petclinic.yml +++ b/docker-compose_spring-petclinic.yml @@ -52,7 +52,6 @@ services: - jenkins_data:/var/jenkins_home - ./jenkins.yaml:/var/jenkins_home/casc_configs/jenkins.yaml - /var/run/docker.sock:/var/run/docker.sock - - ./target:/var/jenkins_home/target networks: - custom-network