create branch for docker compose

This commit is contained in:
sunt9751 2024-07-17 20:56:56 -07:00
parent d8fcd11e67
commit e6bbc1cab6
4 changed files with 62 additions and 0 deletions

24
Dockerfile Normal file
View file

@ -0,0 +1,24 @@
# Use an official OpenJDK runtime as a parent image
FROM openjdk
# Set the working directory inside the container
WORKDIR /app
# Copy the Maven wrapper and the pom.xml file
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
# Copy the project source code
COPY src ./src
# Package the application
RUN ./mvnw package
# Copy the JAR file to the app directory
COPY target/*.jar app.jar
# Run the jar file
CMD ["java", "-jar", "app.jar"]
# Expose the port the app runs on
EXPOSE 8080

View file

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

27
spring-petclinic.yml Normal file
View file

@ -0,0 +1,27 @@
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
volumes:
prometheus_data:
networks:
custom-network:

View file

@ -23,3 +23,9 @@ logging.level.org.springframework=INFO
# Maximum time static resources should be cached
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