mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 23:05:49 +00:00
Merge pull request #6 from CChariot/FinalProject_main
Final project main
This commit is contained in:
commit
bce7750a3a
4 changed files with 53 additions and 24 deletions
35
Dockerfile
35
Dockerfile
|
@ -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
32
Jenkinsfile
vendored
|
@ -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 {
|
||||||
|
|
|
@ -35,6 +35,7 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
|
||||||
|
|
||||||
jenkins:
|
jenkins:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
|
|
|
@ -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']
|
Loading…
Reference in a new issue