This commit is contained in:
Lihan 2024-07-28 00:48:05 -04:00
parent 6719cc74d2
commit 95786ffbfd
2 changed files with 7 additions and 4 deletions

View file

@ -11,13 +11,15 @@ COPY mvnw pom.xml ./
# Copy the project source code # Copy the project source code
COPY src ./src COPY src ./src
# Introduce an ARG to act as a cache breaker
ARG CACHEBUSTER=unknown
# Package the application # Package the application
RUN ./mvnw clean package -Dmaven.test.skip=true RUN ./mvnw clean package -Dmaven.test.skip=true
RUN ls -alh /app/target/ RUN ls -alh /app/target/
# Copy the JAR file to the app directory # Move the JAR file to the app directory (update this if necessary based on actual JAR names)
WORKDIR /app COPY target/*.jar /app/app.jar
COPY /var/jenkins_home/workspace/ing-petclinic_use_docker_compose/target/spring-petclinic-3.3.0-SNAPSHOT.jar /app/app.jar
# Run the jar file # Run the jar file
CMD ["java", "-jar", "app.jar"] CMD ["java", "-jar", "app.jar"]

3
Jenkinsfile vendored
View file

@ -21,7 +21,8 @@ pipeline {
steps { steps {
script { script {
echo "Building Docker Image..." echo "Building Docker Image..."
def dockerImage = docker.build("spring-petclinic", "--no-cache .") // Add a cache buster to force no-cache on certain steps
def dockerImage = docker.build("spring-petclinic", "--build-arg CACHEBUSTER=$(date +%s) --no-cache .")
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