Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
b4510b30f5
|
|||
|
627315ede9
|
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"]
|
||||||
@@ -22,10 +22,10 @@ This utility uses:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker pull bootmediaalix/snowflakeservice
|
docker pull bootmediaalix/snowflakeservice
|
||||||
docker run -e %{set required .env, see below} -p 9567:9567 -v /data/b00tload-services/snowflake:%{desired path on host} bootmediaalix/snowflakeservice
|
docker run -e %{set required .env, see below} -p 9567:9567 -v %{desired path on host}:/data/b00tload-tools/snowflake bootmediaalix/snowflakeservice
|
||||||
```
|
```
|
||||||
### Containerless
|
### Containerless
|
||||||
A containerless installation is possible, although not supported. For development convenience the application base directory is located in `~/.b00tload-services/snowflake` instead of `/data/b00tload-services/snowflake`.
|
A containerless installation is possible, although not supported. For development convenience the application base directory is located in `~/.b00tload-tools/snowflake` instead of `/data/b00tload-tools/snowflake`.
|
||||||
If you want to work containerless you are on your own.
|
If you want to work containerless you are on your own.
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ To run this project, you may add the following environment variables to your .en
|
|||||||
Response example:
|
Response example:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "50990430426234880"
|
"id": "50990430426234880"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
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