Merge pull request #1 from tautaus/use_docker_compose

Use docker compose
This commit is contained in:
bossardme 2024-07-21 15:34:26 -07:00 committed by GitHub
commit 520df2f296
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 69 additions and 2 deletions

View file

@ -1,6 +1,4 @@
# Use an official OpenJDK runtime as a parent image # Use an official OpenJDK runtime as a parent image
# FROM openjdk:17-jdk-alpine
FROM openjdk FROM openjdk
# Set the working directory inside the container # Set the working directory inside the container

View file

@ -0,0 +1,9 @@
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: true

View file

@ -139,6 +139,11 @@
<artifactId>jakarta.xml.bind-api</artifactId> <artifactId>jakarta.xml.bind-api</artifactId>
</dependency> </dependency>
<!-- Micrometer Prometheus Registry -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

8
prometheus.yml Normal file
View file

@ -0,0 +1,8 @@
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'spring-boot-app'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['petclinic:8080']

41
spring-petclinic.yml Normal file
View file

@ -0,0 +1,41 @@
services:
petclinic:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
networks:
- custom-network
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- prometheus_data:/prometheus
- ./prometheus.yml:/etc/prometheus/prometheus.yml
networks:
- custom-network
depends_on:
- petclinic
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
networks:
- custom-network
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
depends_on:
- prometheus
volumes:
prometheus_data:
grafana_data:
networks:
custom-network:

View file

@ -23,3 +23,9 @@ logging.level.org.springframework=INFO
# Maximum time static resources should be cached # Maximum time static resources should be cached
spring.web.resources.cache.cachecontrol.max-age=12h spring.web.resources.cache.cachecontrol.max-age=12h
# Configure the Prometheus endpoint
management.endpoint.prometheus.enabled=true
# Enable Prometheus metrics export
management.metrics.export.prometheus.enabled=true