Compare commits

..

No commits in common. "201c448e8cb95d54596f223724a279090698ea45" and "56a68bc86757ec85ab9ff201c3335a6d96df84ab" have entirely different histories.

9 changed files with 27 additions and 61 deletions

View file

@ -1,13 +0,0 @@
depends_on:
- oci-image-build
steps:
delete-tag:
image: rg.fr-par.scw.cloud/hamburghammer/scaleway-delete-image-plugin
pull: true
settings:
token:
from_secret: docker_token
image-name: dchat/setup-image
tag: "${CI_PIPELINE_NUMBER}"
region: fr-par

View file

@ -12,13 +12,16 @@ variables:
steps: steps:
compile: compile:
image: *image image: *image
group: compile
commands: commands:
- mvn --batch-mode --no-transfer-progress -pl ${MODULE} -am compile - mvn --batch-mode --no-transfer-progress -pl ${MODULE} -am compile
test: test:
image: *image image: *image
group: test
commands: commands:
- mvn --batch-mode --no-transfer-progress -pl ${MODULE} -am test - mvn --batch-mode --no-transfer-progress -pl ${MODULE} -am test
build: build:
image: *image image: *image
group: build
commands: commands:
- mvn --batch-mode --no-transfer-progress -Dmaven.test.skip -pl ${MODULE} -am install - mvn --batch-mode --no-transfer-progress -Dmaven.test.skip -pl ${MODULE} -am install

View file

@ -13,11 +13,13 @@ labels:
platform: linux/amd64 platform: linux/amd64
depends_on: depends_on:
- oci-image-cache-build - java
- nodejs
steps: steps:
build-only: build-only:
image: woodpeckerci/plugin-docker-buildx:2.3.0 image: woodpeckerci/plugin-docker-buildx:2.3.0
group: build
settings: settings:
registry: rg.fr-par.scw.cloud/hamburghammer registry: rg.fr-par.scw.cloud/hamburghammer
username: nologin username: nologin
@ -30,8 +32,6 @@ steps:
pull_image: false pull_image: false
platforms: ${PLATFORM} platforms: ${PLATFORM}
dry-run: true dry-run: true
build_args:
- SETUP_IMAGE=rg.fr-par.scw.cloud/hamburghammer/dchat/setup-image:${CI_PIPELINE_NUMBER}
when: when:
- event: [push, manual] - event: [push, manual]
branch: branch:
@ -39,6 +39,7 @@ steps:
build: build:
image: woodpeckerci/plugin-docker-buildx:2.3.0 image: woodpeckerci/plugin-docker-buildx:2.3.0
group: build
settings: settings:
registry: rg.fr-par.scw.cloud/hamburghammer registry: rg.fr-par.scw.cloud/hamburghammer
username: nologin username: nologin
@ -51,7 +52,5 @@ steps:
pull_image: false pull_image: false
platforms: ${PLATFORM} platforms: ${PLATFORM}
auto_tag: true auto_tag: true
build_args:
- SETUP_IMAGE=rg.fr-par.scw.cloud/hamburghammer/dchat/setup-image:${CI_PIPELINE_NUMBER}
when: when:
- branch: main - branch: main

View file

@ -1,26 +0,0 @@
matrix:
PLATFORM:
# - linux/amd64
- linux/arm64
labels:
platform: linux/amd64
depends_on:
- java
- nodejs
steps:
build:
image: woodpeckerci/plugin-docker-buildx:2.3.0
settings:
registry: rg.fr-par.scw.cloud/hamburghammer
username: nologin
password:
from_secret: docker_token
dockerfile: Dockerfile
target: setup-image
repo: rg.fr-par.scw.cloud/hamburghammer/dchat/setup-image
tag: "${CI_PIPELINE_NUMBER}"
pull_image: false
platforms: ${PLATFORM}

View file

@ -1,17 +1,14 @@
# syntax=docker/dockerfile:1.4.0 # syntax=docker/dockerfile:1.4.0
ARG MAVEN_CLI_OPTS="--batch-mode --no-transfer-progress -Dmaven.test.skip" ARG MAVEN_CLI_OPTS="--batch-mode --no-transfer-progress -Dmaven.test.skip"
ARG SETUP_IMAGE=setup-image
# Copy all project files # Copy all project files
FROM docker.io/maven:3.9-eclipse-temurin-21 AS setup-image FROM docker.io/maven:3.9-eclipse-temurin-21 AS setup
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN --mount=type=cache,target=/root/.m2/ \ RUN --mount=type=cache,target=/root/.m2/ \
mvn ${MAVEN_CLI_OPTS} package mvn ${MAVEN_CLI_OPTS} package
FROM ${SETUP_IMAGE} as setup
# Create final monolith # Create final monolith
FROM docker.io/eclipse-temurin:21-jdk-jammy AS monolith FROM docker.io/eclipse-temurin:21-jdk-jammy AS monolith
WORKDIR /app WORKDIR /app

View file

@ -6,17 +6,24 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List; import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public record ChatGPTResponse(Usage usage, public record ChatGPTResponse(String id,
List<Choice> choices) { String object,
long created,
String model,
Usage usage,
List<Choice> choices,
@JsonProperty("system_fingerprint") String systemFingerprint) {
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public record Usage(@JsonProperty("prompt_tokens") int promptTokens, public record Usage(@JsonProperty("prompt_tokens") int promptTokens,
@JsonProperty("completion_tokens") int completionTokens, @JsonProperty("completion_tokens") int completionTokens,
@JsonProperty("total_tokens") int totalTokens) { @JsonProperty("total_tokens") int totalTokens) {
} }
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public record Choice(Message message) { public record Choice(Message message, @JsonProperty("finish_reason") String finishReason, int index) {
@JsonIgnoreProperties(ignoreUnknown = true)
public record Message(String role, String content) { public record Message(String role, String content) {
} }
} }
} }

View file

@ -18,10 +18,10 @@ import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
public final class App { public class App {
private static final Logger logger = LoggerFactory.getLogger(App.class); private static final Logger logger = LoggerFactory.getLogger(App.class);
public static void main(final String[] args) { public static void main(String[] args) {
final String discordApiKey = System.getenv("DISCORD_API_KEY"); final String discordApiKey = System.getenv("DISCORD_API_KEY");
if (discordApiKey == null) { if (discordApiKey == null) {
logger.error("Missing environment variables: DISCORD_API_KEY"); logger.error("Missing environment variables: DISCORD_API_KEY");
@ -63,12 +63,12 @@ public final class App {
} }
} }
private static void run(final Runnable... apps) throws InterruptedException { private static void run(Runnable... apps) throws InterruptedException {
final List<Callable<Void>> callableApps = Arrays.stream(apps).sequential().map(runnable -> (Callable<Void>) () -> { List<Callable<Void>> callableApps = Arrays.stream(apps).sequential().map(runnable -> (Callable<Void>) () -> {
runnable.run(); runnable.run();
return null; return null;
}).toList(); }).toList();
try (final var executorService = Executors.newFixedThreadPool(apps.length)) { try (var executorService = Executors.newFixedThreadPool(apps.length)) {
executorService.invokeAll(callableApps); executorService.invokeAll(callableApps);
} }
} }

View file

@ -61,7 +61,7 @@
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>1.5.3</version> <version>1.4.14</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -73,7 +73,7 @@
<dependency> <dependency>
<groupId>org.postgresql</groupId> <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
<version>42.7.2</version> <version>42.7.1</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -99,7 +99,7 @@
<dependency> <dependency>
<groupId>io.javalin</groupId> <groupId>io.javalin</groupId>
<artifactId>javalin</artifactId> <artifactId>javalin</artifactId>
<version>6.1.3</version> <version>6.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.javacord</groupId> <groupId>org.javacord</groupId>

View file

@ -36,7 +36,6 @@ public final class WebAPI implements Runnable {
config.http.prefer405over404 = true; // return 405 instead of 404 if path is mapped to different HTTP method config.http.prefer405over404 = true; // return 405 instead of 404 if path is mapped to different HTTP method
config.http.defaultContentType = "application/json"; config.http.defaultContentType = "application/json";
config.useVirtualThreads = true; config.useVirtualThreads = true;
config.showJavalinBanner = false;
config.router.apiBuilder(() -> config.router.apiBuilder(() ->
path("api", () -> { path("api", () -> {
path("servers", () -> crud("configs/{id}", new ConfigCrudHandler(this.serverDBService))); path("servers", () -> crud("configs/{id}", new ConfigCrudHandler(this.serverDBService)));