mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 14:55:50 +00:00
commit
432686b711
4 changed files with 131 additions and 0 deletions
18
Dockerfile.jenkins
Normal file
18
Dockerfile.jenkins
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
FROM jenkins/jenkins:lts
|
||||||
|
|
||||||
|
USER root
|
||||||
|
RUN apt-get update && apt-get install -y docker.io
|
||||||
|
|
||||||
|
# Install plugins
|
||||||
|
RUN jenkins-plugin-cli --plugins prometheus configuration-as-code
|
||||||
|
|
||||||
|
# Copy JCasC configuration file
|
||||||
|
COPY jenkins.yaml /var/jenkins_home/casc_configs/jenkins.yaml
|
||||||
|
|
||||||
|
# Set environment variable for JCasC
|
||||||
|
ENV CASC_JENKINS_CONFIG=/var/jenkins_home/casc_configs/jenkins.yaml
|
||||||
|
|
||||||
|
USER jenkins
|
||||||
|
|
||||||
|
# Expose the port the app runs on
|
||||||
|
EXPOSE 8080
|
49
Jenkinsfile
vendored
Normal file
49
Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
environment {
|
||||||
|
DOCKER_CREDENTIALS_ID = 'your-docker-credentials-id' // Replace with your actual Docker credentials ID
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps {
|
||||||
|
checkout scm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
sh './mvnw clean package'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build Docker Image') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// Build the Docker image
|
||||||
|
sh 'docker build -t petclinic:latest .'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Push Docker Image') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// Push the Docker image to a registry
|
||||||
|
docker.withRegistry('https://index.docker.io/v1/', "${DOCKER_CREDENTIALS_ID}") {
|
||||||
|
sh 'docker tag petclinic:latest your-docker-username/petclinic:latest'
|
||||||
|
sh 'docker push your-docker-username/petclinic:latest'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Deploy') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// Deploy the application using Docker Compose
|
||||||
|
sh 'docker-compose up -d'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
47
jenkins.yaml
Normal file
47
jenkins.yaml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
jenkins:
|
||||||
|
systemMessage: "Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n"
|
||||||
|
securityRealm:
|
||||||
|
local:
|
||||||
|
allowsSignup: false
|
||||||
|
users:
|
||||||
|
- id: "admin"
|
||||||
|
password: "admin"
|
||||||
|
authorizationStrategy:
|
||||||
|
loggedInUsersCanDoAnything:
|
||||||
|
allowAnonymousRead: true
|
||||||
|
|
||||||
|
unclassified:
|
||||||
|
location:
|
||||||
|
url: "http://localhost:8080/"
|
||||||
|
prometheus:
|
||||||
|
defaultQuantiles:
|
||||||
|
- name: "0.5"
|
||||||
|
value: 0.5
|
||||||
|
- name: "0.9"
|
||||||
|
value: 0.9
|
||||||
|
- name: "0.99"
|
||||||
|
value: 0.99
|
||||||
|
defaultBuckets:
|
||||||
|
- name: "0.1"
|
||||||
|
value: 0.1
|
||||||
|
- name: "0.2"
|
||||||
|
value: 0.2
|
||||||
|
- name: "0.5"
|
||||||
|
value: 0.5
|
||||||
|
- name: "1.0"
|
||||||
|
value: 1.0
|
||||||
|
- name: "2.5"
|
||||||
|
value: 2.5
|
||||||
|
- name: "5.0"
|
||||||
|
value: 5.0
|
||||||
|
- name: "10.0"
|
||||||
|
value: 10.0
|
||||||
|
|
||||||
|
tools:
|
||||||
|
installations:
|
||||||
|
- name: "JDK11"
|
||||||
|
jdkInstaller:
|
||||||
|
id: "jdk-11.0.2+9"
|
||||||
|
- name: "Maven3"
|
||||||
|
mavenInstaller:
|
||||||
|
id: "maven-3.6.3"
|
|
@ -35,6 +35,21 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
|
||||||
|
jenkins:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.jenkins
|
||||||
|
ports:
|
||||||
|
- "8081:8080"
|
||||||
|
- "50000:50000"
|
||||||
|
volumes:
|
||||||
|
- jenkins_data:/var/jenkins_home
|
||||||
|
- ./jenkins.yaml:/var/jenkins_home/casc_configs/jenkins.yaml
|
||||||
|
networks:
|
||||||
|
- custom-network
|
||||||
|
environment:
|
||||||
|
- JENKINS_OPTS=--prefix=/jenkins
|
||||||
|
|
||||||
zap:
|
zap:
|
||||||
image: ghcr.io/zaproxy/zaproxy:stable
|
image: ghcr.io/zaproxy/zaproxy:stable
|
||||||
command: zap-baseline.py -t http://petclinic:8080 -g gen.conf -r zap-report.html
|
command: zap-baseline.py -t http://petclinic:8080 -g gen.conf -r zap-report.html
|
||||||
|
@ -54,9 +69,11 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- petclinic
|
- petclinic
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
prometheus_data:
|
prometheus_data:
|
||||||
grafana_data:
|
grafana_data:
|
||||||
|
jenkins_data:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
custom-network:
|
custom-network:
|
||||||
|
|
Loading…
Reference in a new issue