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 src ./src
# Introduce an ARG to act as a cache breaker
ARG CACHEBUSTER=unknown
# Package the application
RUN ./mvnw clean package -Dmaven.test.skip=true
RUN ls -alh /app/target/
# Copy the JAR file to the app directory
WORKDIR /app
COPY /var/jenkins_home/workspace/ing-petclinic_use_docker_compose/target/spring-petclinic-3.3.0-SNAPSHOT.jar /app/app.jar
# 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
CMD ["java", "-jar", "app.jar"]

3
Jenkinsfile vendored
View file

@ -21,7 +21,8 @@ pipeline {
steps {
script {
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}"
// Store the Docker image ID in the environment if needed across stages
env.DOCKER_IMAGE_ID = dockerImage.id