From d6a0b57127db323f65dfb3f142461756bfbd9a51 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sun, 28 Jul 2024 01:05:45 -0400 Subject: [PATCH] ahhhh --- Dockerfile | 19 +++---------------- Jenkinsfile | 10 ++++------ 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index ae99560fd..ce19ac4ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,11 @@ # Use an official OpenJDK runtime as a parent image -FROM openjdk +FROM openjdk:11-jdk-slim # 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 - -# 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 +# Copy the JAR file to the app directory (adjust this path according to your actual JAR file name in the target directory) +COPY target/*.jar app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] diff --git a/Jenkinsfile b/Jenkinsfile index 9501332f3..dfd48c586 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,11 +17,11 @@ pipeline { } } - stage('Prepare Environment') { + stage('Build JAR') { steps { script { - sh "pwd" // Prints the current working directory - sh "ls -alh" // Lists all files in the current directory + echo "Building JAR..." + sh './mvnw clean package -Dmaven.test.skip=true' } } } @@ -30,8 +30,7 @@ pipeline { steps { script { echo "Building Docker Image..." - // Correctly escape dollar signs in Groovy string - def dockerImage = docker.build("spring-petclinic", "--no-cache --build-arg FORCE_REBUILD=$(date +%s) .") + def dockerImage = docker.build("spring-petclinic", "--no-cache .") echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages env.DOCKER_IMAGE_ID = dockerImage.id @@ -40,7 +39,6 @@ pipeline { } // Further stages would reference env.DOCKER_IMAGE_ID if needed - } post {