Added healthcheck
pom.xml: Bump version, update dependencies Dockerfile: Added build step, Added healthcheck SnowflakeService.java: added endpoint for health check
This commit is contained in:
21
Dockerfile
21
Dockerfile
@@ -1,9 +1,24 @@
|
|||||||
|
#
|
||||||
|
# Build
|
||||||
|
#
|
||||||
|
FROM maven:3.9.7-eclipse-temurin-21-alpine AS build
|
||||||
|
ENV HOME=/usr/app
|
||||||
|
RUN mkdir -p $HOME
|
||||||
|
WORKDIR $HOME
|
||||||
|
ADD . $HOME
|
||||||
|
RUN mvn -f $HOME/pom.xml clean compile assembly:single
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Package
|
||||||
|
#
|
||||||
FROM eclipse-temurin:21-jre-alpine
|
FROM eclipse-temurin:21-jre-alpine
|
||||||
|
|
||||||
LABEL authors="B00tLoad_"
|
LABEL authors="B00tLoad_"
|
||||||
|
ARG JAR_FILE=/usr/app/target/*.jar
|
||||||
|
RUN apk --no-cache add curl
|
||||||
RUN mkdir -p /opt/app
|
RUN mkdir -p /opt/app
|
||||||
RUN mkdir -p /data/b00tload-tools/snowflake
|
RUN mkdir -p /data/b00tload-tools/snowflake
|
||||||
|
HEALTHCHECK CMD curl -f http://localhost:9567/health || exit 1
|
||||||
COPY target/SnowflakeService-jar-with-dependencies.jar /opt/app
|
COPY --from=build $JAR_FILE /opt/app
|
||||||
CMD ["java", "-jar", "/opt/app/SnowflakeService-jar-with-dependencies.jar", "--docker"]
|
CMD ["java", "-jar", "/opt/app/SnowflakeService-jar-with-dependencies.jar", "--docker"]
|
||||||
8
pom.xml
8
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>space.b00tload.services</groupId>
|
<groupId>space.b00tload.services</groupId>
|
||||||
<artifactId>SnowflakeService</artifactId>
|
<artifactId>SnowflakeService</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.1.0</version>
|
||||||
|
|
||||||
<name>SnowflakeService</name>
|
<name>SnowflakeService</name>
|
||||||
<description>A tool/microservice to centrally generate snowflake IDs.</description>
|
<description>A tool/microservice to centrally generate snowflake IDs.</description>
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.javalin</groupId>
|
<groupId>io.javalin</groupId>
|
||||||
<artifactId>javalin</artifactId>
|
<artifactId>javalin</artifactId>
|
||||||
<version>6.1.3</version>
|
<version>6.1.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aayushatharva.brotli4j</groupId>
|
<groupId>com.aayushatharva.brotli4j</groupId>
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.10.1</version>
|
<version>2.11.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.7.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<tags>
|
<tags>
|
||||||
<tag>
|
<tag>
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ public class SnowflakeService {
|
|||||||
LoggerFactory.getLogger(config.getClass()).info("{} served in {}ms to {}(UA: \"{}\")", ctx.fullUrl(), executionTimeMs, ctx.req().getRemoteAddr(), ctx.userAgent());
|
LoggerFactory.getLogger(config.getClass()).info("{} served in {}ms to {}(UA: \"{}\")", ctx.fullUrl(), executionTimeMs, ctx.req().getRemoteAddr(), ctx.userAgent());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
endpointServer.addEndpoint(new Endpoint(HandlerType.GET, "health", ctx -> {
|
||||||
|
JsonObject ret = new JsonObject();
|
||||||
|
ret.addProperty("status", "UP");
|
||||||
|
ctx.status(200).result(ret.toString()).contentType(ContentType.APPLICATION_JSON);
|
||||||
|
}));
|
||||||
endpointServer.addEndpoint(new Endpoint(HandlerType.GET, "generate", ctx -> {
|
endpointServer.addEndpoint(new Endpoint(HandlerType.GET, "generate", ctx -> {
|
||||||
JsonObject ret = new JsonObject();
|
JsonObject ret = new JsonObject();
|
||||||
ret.addProperty("id", SnowflakeIDGenerator.getInstance().generateID());
|
ret.addProperty("id", SnowflakeIDGenerator.getInstance().generateID());
|
||||||
|
|||||||
Reference in New Issue
Block a user