Compare commits
No commits in common. "c8c3f702542d65855edff9b93c560b68abc79ebc" and "e7e601a28b9a6e7d467221e288dbe089e2099aef" have entirely different histories.
c8c3f70254
...
e7e601a28b
85 changed files with 255 additions and 662 deletions
|
@ -1,13 +0,0 @@
|
||||||
*
|
|
||||||
!db/src/
|
|
||||||
!db/pom.xml
|
|
||||||
!bot/src/
|
|
||||||
!bot/pom.xml
|
|
||||||
!migration/src/
|
|
||||||
!migration/pom.xml
|
|
||||||
!web/src/
|
|
||||||
!web/pom.xml
|
|
||||||
!pom.xml
|
|
||||||
web/src/ui/node_modules
|
|
||||||
web/src/ui/node
|
|
||||||
web/src/ui/dist
|
|
13
.dockerignore
Normal file
13
.dockerignore
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
*
|
||||||
|
!src/
|
||||||
|
!pom.xml
|
||||||
|
!ui/package*.json
|
||||||
|
!ui/postcss.config.js
|
||||||
|
!ui/tailwind.config.js
|
||||||
|
!ui/env.d..ts
|
||||||
|
!ui/vite.config.ts
|
||||||
|
!ui/tsconfig.json
|
||||||
|
!ui/tsconfig.node.json
|
||||||
|
!ui/index.html
|
||||||
|
!ui/public/
|
||||||
|
!ui/src/
|
|
@ -1,43 +0,0 @@
|
||||||
# Stage 1: Build bot
|
|
||||||
FROM docker.io/maven:3.9-eclipse-temurin-19 AS maven
|
|
||||||
WORKDIR /app
|
|
||||||
# Copy the dependency specifications
|
|
||||||
COPY pom.xml .
|
|
||||||
COPY db/pom.xml db/
|
|
||||||
COPY bot/pom.xml bot/
|
|
||||||
COPY migration/pom.xml migration/
|
|
||||||
COPY web/pom.xml web/
|
|
||||||
# Resolve dependencies for shared libraries
|
|
||||||
RUN mvn -pl db -am dependency:go-offline
|
|
||||||
# Install the shared libraries in the local Maven repo (`.m2`)
|
|
||||||
# This will also install the `root` module.
|
|
||||||
COPY db db
|
|
||||||
RUN mvn -pl db -am install
|
|
||||||
# Resolve dependencies for modules without dependencies to each other
|
|
||||||
RUN mvn dependency:go-offline
|
|
||||||
# Build modules
|
|
||||||
COPY web web
|
|
||||||
RUN mvn -pl web package
|
|
||||||
COPY bot bot
|
|
||||||
RUN mvn -pl bot package
|
|
||||||
COPY migration migration
|
|
||||||
RUN mvn -pl migration package
|
|
||||||
|
|
||||||
# Stage 2: Create final web
|
|
||||||
FROM docker.io/eclipse-temurin:19-jdk-alpine AS web
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=maven /app/web/target/web-*-fat.jar /app/web.jar
|
|
||||||
EXPOSE 8080
|
|
||||||
CMD ["java", "-jar", "/app/web.jar"]
|
|
||||||
|
|
||||||
# Stage 2: Create final migration
|
|
||||||
FROM docker.io/eclipse-temurin:19-jdk-alpine AS migration
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=maven /app/migration/target/migration-*-fat.jar /app/migration.jar
|
|
||||||
CMD ["java", "-jar", "/app/migration.jar"]
|
|
||||||
|
|
||||||
# Stage 2: Create final bot
|
|
||||||
FROM docker.io/eclipse-temurin:19-jdk-alpine AS bot
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=maven /app/bot/target/bot-*-fat.jar /app/bot.jar
|
|
||||||
CMD ["java", "-jar", "/app/bot.jar"]
|
|
25
Dockerfile
Normal file
25
Dockerfile
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Stage 1: Build java application
|
||||||
|
FROM docker.io/maven:3.9-eclipse-temurin-19 AS maven
|
||||||
|
WORKDIR /app
|
||||||
|
COPY pom.xml .
|
||||||
|
RUN mvn dependency:go-offline
|
||||||
|
RUN mvn package
|
||||||
|
COPY src/ /app/src/
|
||||||
|
RUN mvn package
|
||||||
|
|
||||||
|
# Stage 2: Build vuejs application
|
||||||
|
FROM docker.io/node:18-slim AS vuejs
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ./ui/package* .
|
||||||
|
RUN npm ci
|
||||||
|
COPY ./ui .
|
||||||
|
RUN npm run build-only
|
||||||
|
|
||||||
|
# Stage 3: Create the jlink app
|
||||||
|
FROM docker.io/eclipse-temurin:19-jdk-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=maven /app/target/dchat-*-fat.jar /app/dchat.jar
|
||||||
|
COPY --from=vuejs /app/dist /app/ui/dist
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
CMD ["java", "--enable-preview", "-jar", "/app/dchat.jar"]
|
81
bot/pom.xml
81
bot/pom.xml
|
@ -1,81 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<artifactId>dchat</artifactId>
|
|
||||||
<groupId>de.hhhammer.dchat</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>bot</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<name>bot</name>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>de.hhhammer.dchat</groupId>
|
|
||||||
<artifactId>db</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.javacord</groupId>
|
|
||||||
<artifactId>javacord</artifactId>
|
|
||||||
<version>3.8.0</version>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
<artifactId>log4j-to-slf4j</artifactId>
|
|
||||||
<version>2.20.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<compilerArgs>
|
|
||||||
<compilerArg>--enable-preview</compilerArg>
|
|
||||||
</compilerArgs>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
|
||||||
<shadedClassifierName>fat</shadedClassifierName>
|
|
||||||
<transformers>
|
|
||||||
<transformer
|
|
||||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
|
||||||
<manifestEntries>
|
|
||||||
<Main-Class>de.hhhammer.dchat.bot.App</Main-Class>
|
|
||||||
</manifestEntries>
|
|
||||||
</transformer>
|
|
||||||
</transformers>
|
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/*.SF</exclude>
|
|
||||||
<exclude>META-INF/*.DSA</exclude>
|
|
||||||
<exclude>META-INF/*.RSA</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
|
@ -1,13 +0,0 @@
|
||||||
<configuration>
|
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<logger name="de.hhhammer.dchat" level="DEBUG"/>
|
|
||||||
|
|
||||||
<root level="INFO">
|
|
||||||
<appender-ref ref="STDOUT"/>
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
65
build.sh
65
build.sh
|
@ -1,50 +1,31 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
REPO="git.hhhammer.de/hamburghammer/dchat"
|
||||||
AUTHORS="Augusto Dwenger J. <dwenger@posteo.de>"
|
AUTHORS="Augusto Dwenger J. <dwenger@posteo.de>"
|
||||||
URL="https://${REPO}"
|
URL="https://${REPO}"
|
||||||
VENDOR="hamburghammer"
|
VENDOR="hamburghammer"
|
||||||
|
TITLE="dchat"
|
||||||
build() {
|
|
||||||
CREATED=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
||||||
REVISION=$(git rev-parse HEAD)
|
|
||||||
|
|
||||||
IMAGE_LATEST="${REPO}:latest"
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
podman build \
|
|
||||||
$DOCKER_BUILD_ARGS \
|
|
||||||
-t $IMAGE_LATEST \
|
|
||||||
--label "org.opencontainers.image.revision=${REVISION}" \
|
|
||||||
--label "org.opencontainers.image.version=${TAG}" \
|
|
||||||
--label "org.opencontainers.image.authors=${AUTHORS}" \
|
|
||||||
--label "org.opencontainers.image.created=${CREATED}" \
|
|
||||||
--label "org.opencontainers.image.source=${URL}" \
|
|
||||||
--label "org.opencontainers.image.vendor=${VENDOR}" \
|
|
||||||
--label "org.opencontainers.image.title=${TITLE}" \
|
|
||||||
--label "org.opencontainers.image.description=${DESCRIPTION}" \
|
|
||||||
. || exit $?
|
|
||||||
|
|
||||||
if [ "$PUSH_LATEST" == "1" ]; then
|
|
||||||
podman push "${IMAGE_LATEST}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "start building bot"
|
|
||||||
REPO="git.hhhammer.de/hamburghammer/dchat/bot"
|
|
||||||
TITLE="dchat-bot"
|
|
||||||
DESCRIPTION="A Discord bot to chat with ChatGPT from OpenAI"
|
DESCRIPTION="A Discord bot to chat with ChatGPT from OpenAI"
|
||||||
DOCKER_BUILD_ARGS="--target bot"
|
CREATED=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
build
|
REVISION=$(git rev-parse HEAD)
|
||||||
|
|
||||||
echo "start building web"
|
IMAGE_LATEST="${REPO}:latest"
|
||||||
REPO="git.hhhammer.de/hamburghammer/dchat/web"
|
|
||||||
TITLE="dchat-web"
|
# shellcheck disable=SC2086
|
||||||
DESCRIPTION="A web API and UI for the dchat-bot configuration"
|
podman build \
|
||||||
DOCKER_BUILD_ARGS="--target web"
|
$DOCKER_BUILD_ARGS \
|
||||||
build
|
-t $IMAGE_LATEST \
|
||||||
|
--label "org.opencontainers.image.revision=${REVISION}" \
|
||||||
|
--label "org.opencontainers.image.version=${TAG}" \
|
||||||
|
--label "org.opencontainers.image.authors=${AUTHORS}" \
|
||||||
|
--label "org.opencontainers.image.created=${CREATED}" \
|
||||||
|
--label "org.opencontainers.image.source=${URL}" \
|
||||||
|
--label "org.opencontainers.image.vendor=${VENDOR}" \
|
||||||
|
--label "org.opencontainers.image.title=${TITLE}" \
|
||||||
|
--label "org.opencontainers.image.description=${DESCRIPTION}" \
|
||||||
|
. || exit $?
|
||||||
|
|
||||||
|
if [ "$PUSH_LATEST" == "1" ]; then
|
||||||
|
podman push "${IMAGE_LATEST}"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "start building migration"
|
|
||||||
REPO="git.hhhammer.de/hamburghammer/dchat/migration"
|
|
||||||
TITLE="dchat-migration"
|
|
||||||
DESCRIPTION="A migration tool for the dchat database"
|
|
||||||
DOCKER_BUILD_ARGS="--target migration"
|
|
||||||
build
|
|
||||||
|
|
31
db/pom.xml
31
db/pom.xml
|
@ -1,31 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<artifactId>dchat</artifactId>
|
|
||||||
<groupId>de.hhhammer.dchat</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>db</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<name>db</name>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.postgresql</groupId>
|
|
||||||
<artifactId>postgresql</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>2.15.0-rc2</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
|
|
||||||
</build>
|
|
||||||
</project>
|
|
|
@ -2,8 +2,8 @@ version: "3"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
bot:
|
bot:
|
||||||
image: git.hhhammer.de/hamburghammer/dchat/bot:latest
|
image: git.hhhammer.de/hamburghammer/dchat:latest
|
||||||
build: ./bot/
|
build: .
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
@ -13,30 +13,8 @@ services:
|
||||||
- POSTGRES_USER=<postgres-user>
|
- POSTGRES_USER=<postgres-user>
|
||||||
- POSTGRES_PASSWORD=<postgres-password>
|
- POSTGRES_PASSWORD=<postgres-password>
|
||||||
- POSTGRES_URL=jdbc:postgresql://db:5432/dchat
|
- POSTGRES_URL=jdbc:postgresql://db:5432/dchat
|
||||||
|
- API_PORT=8080
|
||||||
- JDK_JAVA_OPTIONS="--enable-preview"
|
- JDK_JAVA_OPTIONS="--enable-preview"
|
||||||
|
|
||||||
web:
|
|
||||||
image: git.hhhammer.de/hamburghammer/dchat/web:latest
|
|
||||||
build: ./web/
|
|
||||||
restart: unless-stopped
|
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
environment:
|
|
||||||
- POSTGRES_USER=<postgres-user>
|
|
||||||
- POSTGRES_PASSWORD=<postgres-password>
|
|
||||||
- POSTGRES_URL=jdbc:postgresql://db:5432/dchat
|
|
||||||
- JDK_JAVA_OPTIONS="--enable-preview"
|
|
||||||
|
|
||||||
migration:
|
|
||||||
image: git.hhhammer.de/hamburghammer/dchat/migration:latest
|
|
||||||
build: ./migration/
|
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
environment:
|
|
||||||
- POSTGRES_USER=<postgres-user>
|
|
||||||
- POSTGRES_PASSWORD=<postgres-password>
|
|
||||||
- POSTGRES_URL=jdbc:postgresql://db:5432/dchat
|
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: docker.io/postgres:15-alpine
|
image: docker.io/postgres:15-alpine
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<artifactId>dchat</artifactId>
|
|
||||||
<groupId>de.hhhammer.dchat</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>migration</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<name>migration</name>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.postgresql</groupId>
|
|
||||||
<artifactId>postgresql</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
|
||||||
<shadedClassifierName>fat</shadedClassifierName>
|
|
||||||
<transformers>
|
|
||||||
<transformer
|
|
||||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
|
||||||
<manifestEntries>
|
|
||||||
<Main-Class>de.hhhammer.dchat.migration.App</Main-Class>
|
|
||||||
</manifestEntries>
|
|
||||||
</transformer>
|
|
||||||
</transformers>
|
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/*.SF</exclude>
|
|
||||||
<exclude>META-INF/*.DSA</exclude>
|
|
||||||
<exclude>META-INF/*.RSA</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
|
@ -1,25 +0,0 @@
|
||||||
package de.hhhammer.dchat.migration;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hello world!
|
|
||||||
*/
|
|
||||||
public class App {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(App.class);
|
|
||||||
private static final String DB_MIGRATION_PATH = "db/schema.sql";
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String postgresUser = System.getenv("POSTGRES_USER");
|
|
||||||
String postgresPassword = System.getenv("POSTGRES_PASSWORD");
|
|
||||||
String postgresUrl = System.getenv("POSTGRES_URL");
|
|
||||||
if (postgresUser == null || postgresPassword == null || postgresUrl == null) {
|
|
||||||
logger.error("Missing environment variables: POSTGRES_USER and/or POSTGRES_PASSWORD and/or POSTGRES_URL");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
var migrationExecutor = new MigrationExecutor(postgresUrl, postgresUser, postgresPassword);
|
|
||||||
var dbMigrator = new DBMigrator(migrationExecutor, DB_MIGRATION_PATH);
|
|
||||||
dbMigrator.run();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<configuration>
|
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<logger name="de.hhhammer.dchat" level="DEBUG"/>
|
|
||||||
|
|
||||||
<root level="INFO">
|
|
||||||
<appender-ref ref="STDOUT"/>
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
177
pom.xml
177
pom.xml
|
@ -7,9 +7,6 @@
|
||||||
<groupId>de.hhhammer.dchat</groupId>
|
<groupId>de.hhhammer.dchat</groupId>
|
||||||
<artifactId>dchat</artifactId>
|
<artifactId>dchat</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<!-- FIXME change it to the project's website -->
|
|
||||||
<url>http://www.example.com</url>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>19</maven.compiler.source>
|
<maven.compiler.source>19</maven.compiler.source>
|
||||||
|
@ -17,111 +14,105 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
<!-- logging -->
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.javacord</groupId>
|
||||||
|
<artifactId>javacord</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.15.0-rc2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
<version>2.14.2</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>42.6.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.javalin</groupId>
|
||||||
|
<artifactId>javalin</artifactId>
|
||||||
|
<version>5.5.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- logging -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-to-slf4j</artifactId>
|
||||||
|
<version>2.20.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>2.0.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<version>1.4.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains</groupId>
|
<groupId>org.jetbrains</groupId>
|
||||||
<artifactId>annotations</artifactId>
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>24.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
<version>2.0.7</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
<version>1.4.6</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains</groupId>
|
|
||||||
<artifactId>annotations</artifactId>
|
|
||||||
<version>24.0.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.postgresql</groupId>
|
|
||||||
<artifactId>postgresql</artifactId>
|
|
||||||
<version>42.6.0</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<plugins>
|
||||||
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
<plugin>
|
||||||
<plugins>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<plugin>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<groupId>com.google.cloud.tools</groupId>
|
<version>3.11.0</version>
|
||||||
<artifactId>jib-maven-plugin</artifactId>
|
<configuration>
|
||||||
<version>3.3.2</version>
|
<compilerArgs>
|
||||||
</plugin>
|
<compilerArg>--enable-preview</compilerArg>
|
||||||
|
</compilerArgs>
|
||||||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
</configuration>
|
||||||
<plugin>
|
</plugin>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<plugin>
|
||||||
<version>3.1.0</version>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
</plugin>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
<version>3.2.3</version>
|
||||||
<plugin>
|
<configuration>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||||
<version>3.0.2</version>
|
<shadedClassifierName>fat</shadedClassifierName>
|
||||||
</plugin>
|
<transformers>
|
||||||
<plugin>
|
<transformer
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
<version>3.11.0</version>
|
<manifestEntries>
|
||||||
</plugin>
|
<Main-Class>de.hhhammer.dchat.Main</Main-Class>
|
||||||
<plugin>
|
</manifestEntries>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
</transformer>
|
||||||
<version>2.22.1</version>
|
</transformers>
|
||||||
</plugin>
|
<filters>
|
||||||
<plugin>
|
<filter>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifact>*:*</artifact>
|
||||||
<version>3.0.2</version>
|
<excludes>
|
||||||
</plugin>
|
<exclude>META-INF/*.SF</exclude>
|
||||||
<plugin>
|
<exclude>META-INF/*.DSA</exclude>
|
||||||
<artifactId>maven-install-plugin</artifactId>
|
<exclude>META-INF/*.RSA</exclude>
|
||||||
<version>2.5.2</version>
|
</excludes>
|
||||||
</plugin>
|
</filter>
|
||||||
<plugin>
|
</filters>
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
</configuration>
|
||||||
<version>2.8.2</version>
|
<executions>
|
||||||
</plugin>
|
<execution>
|
||||||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
<phase>package</phase>
|
||||||
<plugin>
|
<goals>
|
||||||
<artifactId>maven-site-plugin</artifactId>
|
<goal>shade</goal>
|
||||||
<version>3.7.1</version>
|
</goals>
|
||||||
</plugin>
|
</execution>
|
||||||
<plugin>
|
</executions>
|
||||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
</plugin>
|
||||||
<version>3.0.0</version>
|
</plugins>
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.3</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
</build>
|
||||||
<modules>
|
|
||||||
<module>bot</module>
|
|
||||||
<module>db</module>
|
|
||||||
<module>web</module>
|
|
||||||
<module>migration</module>
|
|
||||||
</modules>
|
|
||||||
</project>
|
</project>
|
|
@ -1,5 +1,7 @@
|
||||||
package de.hhhammer.dchat.migration;
|
package de.hhhammer.dchat;
|
||||||
|
|
||||||
|
import de.hhhammer.dchat.migration.DBMigrationException;
|
||||||
|
import de.hhhammer.dchat.migration.MigrationExecutor;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package de.hhhammer.dchat.bot;
|
package de.hhhammer.dchat;
|
||||||
|
|
||||||
import de.hhhammer.dchat.bot.discord.MessageCreateHandler;
|
|
||||||
import de.hhhammer.dchat.bot.discord.ServerMessageHandler;
|
|
||||||
import de.hhhammer.dchat.bot.discord.UserMessageHandler;
|
|
||||||
import de.hhhammer.dchat.bot.openai.ChatGPTService;
|
|
||||||
import de.hhhammer.dchat.db.ServerDBService;
|
import de.hhhammer.dchat.db.ServerDBService;
|
||||||
import de.hhhammer.dchat.db.UserDBService;
|
import de.hhhammer.dchat.db.UserDBService;
|
||||||
|
import de.hhhammer.dchat.discord.MessageCreateHandler;
|
||||||
|
import de.hhhammer.dchat.discord.ServerMessageHandler;
|
||||||
|
import de.hhhammer.dchat.discord.UserMessageHandler;
|
||||||
|
import de.hhhammer.dchat.openai.ChatGPTService;
|
||||||
import org.javacord.api.DiscordApi;
|
import org.javacord.api.DiscordApi;
|
||||||
import org.javacord.api.DiscordApiBuilder;
|
import org.javacord.api.DiscordApiBuilder;
|
||||||
import org.javacord.api.interaction.SlashCommand;
|
import org.javacord.api.interaction.SlashCommand;
|
|
@ -1,15 +1,29 @@
|
||||||
package de.hhhammer.dchat.bot;
|
package de.hhhammer.dchat;
|
||||||
|
|
||||||
import de.hhhammer.dchat.bot.openai.ChatGPTService;
|
|
||||||
import de.hhhammer.dchat.db.ServerDBService;
|
import de.hhhammer.dchat.db.ServerDBService;
|
||||||
import de.hhhammer.dchat.db.UserDBService;
|
import de.hhhammer.dchat.db.UserDBService;
|
||||||
|
import de.hhhammer.dchat.migration.MigrationExecutor;
|
||||||
|
import de.hhhammer.dchat.openai.ChatGPTService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(Main.class);
|
||||||
|
private static final String DB_MIGRATION_PATH = "db/schema.sql";
|
||||||
|
private final DiscordBot discordBot;
|
||||||
|
private final WebAPI webAPI;
|
||||||
|
private final DBMigrator dbMigrator;
|
||||||
|
|
||||||
|
public Main(DiscordBot discordBot, WebAPI webAPI, DBMigrator dbMigrator) {
|
||||||
|
this.discordBot = discordBot;
|
||||||
|
this.webAPI = webAPI;
|
||||||
|
this.dbMigrator = dbMigrator;
|
||||||
|
}
|
||||||
|
|
||||||
public class App {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(App.class);
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String discordApiKey = System.getenv("DISCORD_API_KEY");
|
String discordApiKey = System.getenv("DISCORD_API_KEY");
|
||||||
|
@ -30,11 +44,27 @@ public class App {
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String apiPortStr = System.getenv("API_PORT") != null ? System.getenv("API_PORT") : "8080";
|
||||||
|
int apiPort = Integer.parseInt(apiPortStr);
|
||||||
|
|
||||||
var chatGPTService = new ChatGPTService(openaiApiKey, HttpClient.newHttpClient());
|
var chatGPTService = new ChatGPTService(openaiApiKey, HttpClient.newHttpClient());
|
||||||
var serverDBService = new ServerDBService(postgresUrl, postgresUser, postgresPassword);
|
var serverDBService = new ServerDBService(postgresUrl, postgresUser, postgresPassword);
|
||||||
var userDBService = new UserDBService(postgresUrl, postgresUser, postgresPassword);
|
var userDBService = new UserDBService(postgresUrl, postgresUser, postgresPassword);
|
||||||
|
|
||||||
var discordBot = new DiscordBot(serverDBService, userDBService, chatGPTService, discordApiKey);
|
var discordBot = new DiscordBot(serverDBService, userDBService, chatGPTService, discordApiKey);
|
||||||
discordBot.run();
|
var webAPI = new WebAPI(serverDBService, userDBService, apiPort);
|
||||||
|
var dbMigrator = new DBMigrator(new MigrationExecutor(postgresUrl, postgresUser, postgresPassword), DB_MIGRATION_PATH);
|
||||||
|
new Main(discordBot, webAPI, dbMigrator).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
logger.info("Starting services...");
|
||||||
|
try (var executor = Executors.newFixedThreadPool(2)) {
|
||||||
|
executor.submit(dbMigrator).get(); // Waiting for migrations
|
||||||
|
executor.submit(discordBot);
|
||||||
|
executor.submit(webAPI);
|
||||||
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package de.hhhammer.dchat.web;
|
package de.hhhammer.dchat;
|
||||||
|
|
||||||
import de.hhhammer.dchat.db.ServerDBService;
|
import de.hhhammer.dchat.db.ServerDBService;
|
||||||
import de.hhhammer.dchat.db.UserDBService;
|
import de.hhhammer.dchat.db.UserDBService;
|
||||||
|
@ -34,8 +34,8 @@ public class WebAPI implements Runnable {
|
||||||
config.http.defaultContentType = "application/json";
|
config.http.defaultContentType = "application/json";
|
||||||
config.staticFiles.add(staticFileConfig -> {
|
config.staticFiles.add(staticFileConfig -> {
|
||||||
staticFileConfig.hostedPath = "/";
|
staticFileConfig.hostedPath = "/";
|
||||||
staticFileConfig.location = Location.CLASSPATH;
|
staticFileConfig.location = Location.EXTERNAL;
|
||||||
staticFileConfig.directory = "ui";
|
staticFileConfig.directory = "./ui/dist/";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
|
@ -52,7 +52,7 @@ public class WebAPI implements Runnable {
|
||||||
});
|
});
|
||||||
app.after(ctx -> {
|
app.after(ctx -> {
|
||||||
if (!ctx.path().startsWith("/api") && (ctx.status().equals(HttpStatus.NOT_FOUND) || ctx.status().equals(HttpStatus.METHOD_NOT_ALLOWED))) {
|
if (!ctx.path().startsWith("/api") && (ctx.status().equals(HttpStatus.NOT_FOUND) || ctx.status().equals(HttpStatus.METHOD_NOT_ALLOWED))) {
|
||||||
ctx.redirect("/");
|
ctx.redirect("/index.html");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.options("*", ctx -> ctx.status(HttpStatus.OK));
|
app.options("*", ctx -> ctx.status(HttpStatus.OK));
|
|
@ -1,4 +1,4 @@
|
||||||
package de.hhhammer.dchat.bot.discord;
|
package de.hhhammer.dchat.discord;
|
||||||
|
|
||||||
import org.javacord.api.entity.message.MessageType;
|
import org.javacord.api.entity.message.MessageType;
|
||||||
import org.javacord.api.event.message.MessageCreateEvent;
|
import org.javacord.api.event.message.MessageCreateEvent;
|
|
@ -1,4 +1,4 @@
|
||||||
package de.hhhammer.dchat.bot.discord;
|
package de.hhhammer.dchat.discord;
|
||||||
|
|
||||||
import org.javacord.api.event.message.MessageCreateEvent;
|
import org.javacord.api.event.message.MessageCreateEvent;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package de.hhhammer.dchat.bot.discord;
|
package de.hhhammer.dchat.discord;
|
||||||
|
|
||||||
import de.hhhammer.dchat.bot.openai.ChatGPTRequestBuilder;
|
|
||||||
import de.hhhammer.dchat.bot.openai.ChatGPTService;
|
|
||||||
import de.hhhammer.dchat.bot.openai.ResponseException;
|
|
||||||
import de.hhhammer.dchat.db.ServerDBService;
|
import de.hhhammer.dchat.db.ServerDBService;
|
||||||
import de.hhhammer.dchat.db.models.server.ServerMessage;
|
import de.hhhammer.dchat.db.models.server.ServerMessage;
|
||||||
|
import de.hhhammer.dchat.openai.ChatGPTRequestBuilder;
|
||||||
|
import de.hhhammer.dchat.openai.ChatGPTService;
|
||||||
|
import de.hhhammer.dchat.openai.ResponseException;
|
||||||
import org.javacord.api.entity.DiscordEntity;
|
import org.javacord.api.entity.DiscordEntity;
|
||||||
import org.javacord.api.entity.message.Message;
|
import org.javacord.api.entity.message.Message;
|
||||||
import org.javacord.api.entity.message.MessageReference;
|
import org.javacord.api.entity.message.MessageReference;
|
|
@ -1,10 +1,10 @@
|
||||||
package de.hhhammer.dchat.bot.discord;
|
package de.hhhammer.dchat.discord;
|
||||||
|
|
||||||
import de.hhhammer.dchat.db.UserDBService;
|
import de.hhhammer.dchat.db.UserDBService;
|
||||||
import de.hhhammer.dchat.db.models.user.UserMessage;
|
import de.hhhammer.dchat.db.models.user.UserMessage;
|
||||||
import de.hhhammer.dchat.bot.openai.ChatGPTRequestBuilder;
|
import de.hhhammer.dchat.openai.ChatGPTRequestBuilder;
|
||||||
import de.hhhammer.dchat.bot.openai.ChatGPTService;
|
import de.hhhammer.dchat.openai.ChatGPTService;
|
||||||
import de.hhhammer.dchat.bot.openai.ResponseException;
|
import de.hhhammer.dchat.openai.ResponseException;
|
||||||
import org.javacord.api.event.message.MessageCreateEvent;
|
import org.javacord.api.event.message.MessageCreateEvent;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
|
@ -1,6 +1,7 @@
|
||||||
package de.hhhammer.dchat.bot.openai;
|
package de.hhhammer.dchat.openai;
|
||||||
|
|
||||||
|
import de.hhhammer.dchat.openai.models.ChatGPTRequest;
|
||||||
|
|
||||||
import de.hhhammer.dchat.bot.openai.models.ChatGPTRequest;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package de.hhhammer.dchat.bot.openai;
|
package de.hhhammer.dchat.openai;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import de.hhhammer.dchat.bot.openai.models.ChatGPTRequest;
|
import de.hhhammer.dchat.openai.models.ChatGPTRequest;
|
||||||
import de.hhhammer.dchat.bot.openai.models.ChatGPTResponse;
|
import de.hhhammer.dchat.openai.models.ChatGPTResponse;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
|
@ -1,4 +1,4 @@
|
||||||
package de.hhhammer.dchat.bot.openai;
|
package de.hhhammer.dchat.openai;
|
||||||
|
|
||||||
public class ResponseException extends Exception {
|
public class ResponseException extends Exception {
|
||||||
public ResponseException(String message) {
|
public ResponseException(String message) {
|
|
@ -1,4 +1,4 @@
|
||||||
package de.hhhammer.dchat.bot.openai.models;
|
package de.hhhammer.dchat.openai.models;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package de.hhhammer.dchat.bot.openai.models;
|
package de.hhhammer.dchat.openai.models;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<logger name="de.hhhammer.dchat" level="DEBUG"/>
|
<logger name="de.hhhammer.dchat" level="DEBUG"/>
|
||||||
|
<logger name="org.javacord.core" level="WARN"/>
|
||||||
<logger name="io.javalin.Javalin" level="INFO"/>
|
<logger name="io.javalin.Javalin" level="INFO"/>
|
||||||
|
|
||||||
<root level="INFO">
|
<root level="INFO">
|
12
ui/.containerignore
Normal file
12
ui/.containerignore
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
*
|
||||||
|
!Caddyfile
|
||||||
|
!package*.json
|
||||||
|
!postcss.config.js
|
||||||
|
!tailwind.config.js
|
||||||
|
!env.d..ts
|
||||||
|
!vite.config.ts
|
||||||
|
!tsconfig.json
|
||||||
|
!tsconfig.node.json
|
||||||
|
!index.html
|
||||||
|
!public/
|
||||||
|
!src/
|
2
web/src/ui/.gitignore → ui/.gitignore
vendored
2
web/src/ui/.gitignore → ui/.gitignore
vendored
|
@ -26,5 +26,3 @@ coverage
|
||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
node
|
|
11
ui/Caddyfile
Normal file
11
ui/Caddyfile
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{$SITE_ADDRESS} {
|
||||||
|
basicauth * {
|
||||||
|
{$AUTH_PASSWORD} {$AUTH_PASSWORD}
|
||||||
|
}
|
||||||
|
|
||||||
|
encode zstd gzip
|
||||||
|
|
||||||
|
root * /app
|
||||||
|
try_files {path} /index.html
|
||||||
|
file_server
|
||||||
|
}
|
16
ui/Containerfile
Normal file
16
ui/Containerfile
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
FROM docker.io/node:18-slim AS build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ./package* .
|
||||||
|
RUN npm ci
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build-only
|
||||||
|
|
||||||
|
FROM docker.io/caddy:2-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ./Caddyfile /
|
||||||
|
COPY --from=build /app/dist /app
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["caddy", "run", "--config", "/Caddyfile"]
|
0
web/src/ui/env.d.ts → ui/env.d.ts
vendored
0
web/src/ui/env.d.ts → ui/env.d.ts
vendored
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
155
web/pom.xml
155
web/pom.xml
|
@ -1,155 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<artifactId>dchat</artifactId>
|
|
||||||
<groupId>de.hhhammer.dchat</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>web</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<name>web</name>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<node.version>v18.16.0</node.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>de.hhhammer.dchat</groupId>
|
|
||||||
<artifactId>db</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.javalin</groupId>
|
|
||||||
<artifactId>javalin</artifactId>
|
|
||||||
<version>5.5.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>2.15.0-rc2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
|
||||||
<version>2.14.2</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<compilerArgs>
|
|
||||||
<compilerArg>--enable-preview</compilerArg>
|
|
||||||
</compilerArgs>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
|
||||||
<shadedClassifierName>fat</shadedClassifierName>
|
|
||||||
<transformers>
|
|
||||||
<transformer
|
|
||||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
|
||||||
<manifestEntries>
|
|
||||||
<Main-Class>de.hhhammer.dchat.web.App</Main-Class>
|
|
||||||
</manifestEntries>
|
|
||||||
</transformer>
|
|
||||||
</transformers>
|
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/*.SF</exclude>
|
|
||||||
<exclude>META-INF/*.DSA</exclude>
|
|
||||||
<exclude>META-INF/*.RSA</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>com.github.eirslett</groupId>
|
|
||||||
<artifactId>frontend-maven-plugin</artifactId>
|
|
||||||
<version>1.9.1</version>
|
|
||||||
<configuration>
|
|
||||||
<nodeVersion>${node.version}</nodeVersion>
|
|
||||||
<workingDirectory>src/ui</workingDirectory>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>Install node and npm</id>
|
|
||||||
<goals>
|
|
||||||
<goal>install-node-and-npm</goal>
|
|
||||||
</goals>
|
|
||||||
<phase>generate-resources</phase>
|
|
||||||
<configuration>
|
|
||||||
<nodeVersion>${node.version}</nodeVersion>
|
|
||||||
<npmVersion>${npm.version}</npmVersion>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
|
|
||||||
<execution>
|
|
||||||
<id>npm install</id>
|
|
||||||
<goals>
|
|
||||||
<goal>npm</goal>
|
|
||||||
</goals>
|
|
||||||
<phase>generate-resources</phase>
|
|
||||||
<configuration>
|
|
||||||
<arguments>install</arguments>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
|
|
||||||
<execution>
|
|
||||||
<id>npm build</id>
|
|
||||||
<goals>
|
|
||||||
<goal>npm</goal>
|
|
||||||
</goals>
|
|
||||||
<phase>generate-resources</phase>
|
|
||||||
<configuration>
|
|
||||||
<arguments>run build-only</arguments>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>Copy Vue frontend into target static folder</id>
|
|
||||||
<phase>process-resources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-resources</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>target/classes/ui</outputDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/ui/dist</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
|
@ -1,32 +0,0 @@
|
||||||
package de.hhhammer.dchat.web;
|
|
||||||
|
|
||||||
import de.hhhammer.dchat.db.ServerDBService;
|
|
||||||
import de.hhhammer.dchat.db.UserDBService;
|
|
||||||
import io.javalin.Javalin;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hello world!
|
|
||||||
*/
|
|
||||||
public class App {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(App.class);
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String postgresUser = System.getenv("POSTGRES_USER");
|
|
||||||
String postgresPassword = System.getenv("POSTGRES_PASSWORD");
|
|
||||||
String postgresUrl = System.getenv("POSTGRES_URL");
|
|
||||||
if (postgresUser == null || postgresPassword == null || postgresUrl == null) {
|
|
||||||
logger.error("Missing environment variables: POSTGRES_USER and/or POSTGRES_PASSWORD and/or POSTGRES_URL");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
var serverDBService = new ServerDBService(postgresUrl, postgresUser, postgresPassword);
|
|
||||||
var userDBService = new UserDBService(postgresUrl, postgresUser, postgresPassword);
|
|
||||||
|
|
||||||
String apiPortStr = System.getenv("API_PORT") != null ? System.getenv("API_PORT") : "8080";
|
|
||||||
int apiPort = Integer.parseInt(apiPortStr);
|
|
||||||
var webApi = new WebAPI(serverDBService, userDBService, apiPort);
|
|
||||||
webApi.run();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue