Skip to content

Commit

Permalink
Various improvements (#2)
Browse files Browse the repository at this point in the history
* Add stats healthcheck
* Use openjdk-slim
* Add banner text
* Add example for JVM tool options
  • Loading branch information
BolZer authored Jun 10, 2024
1 parent 56698f5 commit da19c1b
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
ENTRYPOINT ["java", "-jar", "peppol-bis-billing-validator--runner.jar"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/io/github/easybill/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
7 changes: 7 additions & 0 deletions src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

___. .__.__ .__
____ _____ _________.__.\_ |__ |__| | | |
_/ __ \\__ \ / ___< | | | __ \| | | | |
\ ___/ / __ \_\___ \ \___ | | \_\ \ | |_| |__
\___ >____ /____ >/ ____| |___ /__|____/____/
\/ \/ \/ \/ \/

0 comments on commit da19c1b

Please # to comment.