Merge pull request #6 from CChariot/FinalProject_main

Final project main
This commit is contained in:
88ning 2024-07-28 18:43:04 -07:00 committed by GitHub
commit bce7750a3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 53 additions and 24 deletions

View file

@ -1,14 +1,37 @@
## Use an official OpenJDK runtime as a parent image
#FROM openjdk:11-jdk-slim
#
## Set the working directory inside the container
#WORKDIR /app
#
## 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"]
#
## Expose the port the app runs on
#EXPOSE 8080
# Use an official OpenJDK runtime as a parent image # Use an official OpenJDK runtime as a parent image
FROM openjdk:11-jdk-slim FROM openjdk
# Set the working directory inside the container # Set the working directory inside the container
WORKDIR /app WORKDIR /app
# Copy the JAR file to the app directory (adjust this path according to your actual JAR file name in the target directory) # Copy the Maven wrapper and the pom.xml file
COPY target/*.jar app.jar COPY .mvn/ .mvn
COPY mvnw pom.xml ./
# Copy the project source code
COPY src ./src
# Package the application
RUN ./mvnw clean package
# Copy the JAR file to the app directory
RUN cp /app/target/*.jar app.jar
# Run the jar file # Run the jar file
CMD ["java", "-jar", "app.jar"] CMD ["java", "-jar", "app.jar"]
# Expose the port the app runs on
EXPOSE 8080

32
Jenkinsfile vendored
View file

@ -8,23 +8,23 @@ pipeline {
} }
stages { stages {
stage('Checkout') { // stage('Checkout') {
steps { // steps {
script { // script {
echo "Checking out code..." // echo "Checking out code..."
git url: 'https://github.com/CChariot/spring-petclinic.git', branch: 'FinalProject_main', credentialsId: 'github-token' // git url: 'https://github.com/CChariot/spring-petclinic.git', branch: 'FinalProject_main', credentialsId: 'github-token'
} // }
} // }
} // }
stage('Build JAR') { // stage('Build JAR') {
steps { // steps {
script { // script {
echo "Building JAR..." // echo "Building JAR..."
sh './mvnw clean package -Dmaven.test.skip=true' // sh './mvnw clean package -Dmaven.test.skip=true'
} // }
} // }
} // }
stage('Build Docker Image') { stage('Build Docker Image') {
steps { steps {

View file

@ -35,6 +35,7 @@ services:
depends_on: depends_on:
- prometheus - prometheus
jenkins: jenkins:
build: build:
context: . context: .

View file

@ -6,3 +6,8 @@ scrape_configs:
metrics_path: '/actuator/prometheus' metrics_path: '/actuator/prometheus'
static_configs: static_configs:
- targets: ['petclinic:8080'] - targets: ['petclinic:8080']
- job_name: 'jenkins'
metrics_path: '/prometheus'
static_configs:
- targets: ['localhost:8081']