diff --git a/Dockerfile b/Dockerfile index d9b91fe..3cc8381 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM openjdk:21 +FROM openjdk:21-slim WORKDIR . COPY ./build/peppol-bis-billing-validator--runner.jar . -ENTRYPOINT ["java", "-Xmx512m", "-jar", "peppol-bis-billing-validator--runner.jar"] \ No newline at end of file +ENTRYPOINT ["java", "-jar", "peppol-bis-billing-validator--runner.jar"] \ No newline at end of file diff --git a/README.md b/README.md index 9f66388..612a4fd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # peppol-bis-billing-validator -[![Generic badge](https://img.shields.io/badge/Version-0.1.0-important.svg)]() +[![Generic badge](https://img.shields.io/badge/Version-0.2.0-important.svg)]() [![Generic badge](https://img.shields.io/badge/License-MIT-blue.svg)]() ## Introduction @@ -23,6 +23,8 @@ XML. image: 'easybill/peppol-bis-billing-validator:latest' ports: - '8081:8080' + environment: + JAVA_TOOL_OPTIONS: -Xmx512m healthcheck: test: curl --fail http://localhost:8081/health || exit 0 interval: 10s diff --git a/src/main/java/io/github/easybill/Main.java b/src/main/java/io/github/easybill/Main.java index b38a3c7..472a41b 100644 --- a/src/main/java/io/github/easybill/Main.java +++ b/src/main/java/io/github/easybill/Main.java @@ -2,11 +2,25 @@ import io.quarkus.runtime.Quarkus; import io.quarkus.runtime.annotations.QuarkusMain; +import java.nio.charset.StandardCharsets; @QuarkusMain public class Main { public static void main(String[] args) throws Exception { + Main.printBannerText(); Quarkus.run(args); } + + private static void printBannerText() throws Exception { + try (var bannerStream = Main.class.getResourceAsStream("/banner.txt")) { + if (bannerStream == null) { + throw new Exception("could not read banner file"); + } + + System.out.println( + new String(bannerStream.readAllBytes(), StandardCharsets.UTF_8) + ); + } + } } diff --git a/src/main/java/io/github/easybill/PeppolValidatorApplication.java b/src/main/java/io/github/easybill/PeppolValidatorApplication.java index 11c153f..90a8a5f 100644 --- a/src/main/java/io/github/easybill/PeppolValidatorApplication.java +++ b/src/main/java/io/github/easybill/PeppolValidatorApplication.java @@ -9,7 +9,7 @@ @OpenAPIDefinition( info = @Info( title = "Peppol Validator API", - version = "0.1.0", + version = "0.2.0", contact = @Contact( name = "easybill GmbH", url = "https://github.com/easybill", diff --git a/src/main/java/io/github/easybill/Services/HealthCheck/StatsHealthCheck.java b/src/main/java/io/github/easybill/Services/HealthCheck/StatsHealthCheck.java new file mode 100644 index 0000000..fd2ad78 --- /dev/null +++ b/src/main/java/io/github/easybill/Services/HealthCheck/StatsHealthCheck.java @@ -0,0 +1,41 @@ +package io.github.easybill.Services.HealthCheck; + +import jakarta.enterprise.context.ApplicationScoped; +import java.lang.management.ManagementFactory; +import org.eclipse.microprofile.health.HealthCheck; +import org.eclipse.microprofile.health.HealthCheckResponse; +import org.eclipse.microprofile.health.HealthCheckResponseBuilder; +import org.eclipse.microprofile.health.Liveness; + +@Liveness +@ApplicationScoped +public final class StatsHealthCheck implements HealthCheck { + + @Override + public HealthCheckResponse call() { + HealthCheckResponseBuilder response = HealthCheckResponse.named( + "stats" + ); + + var osBean = ManagementFactory.getOperatingSystemMXBean(); + var memBean = ManagementFactory.getMemoryMXBean(); + + return response + .up() + .withData("osName", osBean.getName()) + .withData("osArch", osBean.getArch()) + .withData( + "heapMemoryUsageMax", + memBean.getHeapMemoryUsage().getMax() + ) + .withData( + "heapMemoryUsageCommitted", + memBean.getHeapMemoryUsage().getCommitted() + ) + .withData( + "heapMemoryUsageUsed", + memBean.getHeapMemoryUsage().getUsed() + ) + .build(); + } +} diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt new file mode 100644 index 0000000..7e70af5 --- /dev/null +++ b/src/main/resources/banner.txt @@ -0,0 +1,7 @@ + + ___. .__.__ .__ + ____ _____ _________.__.\_ |__ |__| | | | +_/ __ \\__ \ / ___< | | | __ \| | | | | +\ ___/ / __ \_\___ \ \___ | | \_\ \ | |_| |__ + \___ >____ /____ >/ ____| |___ /__|____/____/ + \/ \/ \/ \/ \/