mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 07:15:49 +00:00
create branch for docker compose
This commit is contained in:
parent
d8fcd11e67
commit
e6bbc1cab6
4 changed files with 62 additions and 0 deletions
24
Dockerfile
Normal file
24
Dockerfile
Normal 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
|
5
pom.xml
5
pom.xml
|
@ -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>
|
||||||
|
|
27
spring-petclinic.yml
Normal file
27
spring-petclinic.yml
Normal 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:
|
|
@ -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
|
Loading…
Reference in a new issue