Compare commits
1 commit
4f0be9919f
...
dbb45646d4
Author | SHA1 | Date | |
---|---|---|---|
dbb45646d4 |
8 changed files with 87 additions and 60 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"]
|
14
build.sh
14
build.sh
|
@ -3,6 +3,9 @@
|
|||
AUTHORS="Augusto Dwenger J. <dwenger@posteo.de>"
|
||||
URL="https://${REPO}"
|
||||
VENDOR="hamburghammer"
|
||||
TITLE="dchat"
|
||||
DESCRIPTION="A Discord bot to chat with ChatGPT from OpenAI"
|
||||
|
||||
|
||||
build() {
|
||||
CREATED=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
@ -21,7 +24,7 @@ build() {
|
|||
--label "org.opencontainers.image.vendor=${VENDOR}" \
|
||||
--label "org.opencontainers.image.title=${TITLE}" \
|
||||
--label "org.opencontainers.image.description=${DESCRIPTION}" \
|
||||
. || exit $?
|
||||
.. || exit $?
|
||||
|
||||
if [ "$PUSH_LATEST" == "1" ]; then
|
||||
podman push "${IMAGE_LATEST}"
|
||||
|
@ -29,22 +32,25 @@ build() {
|
|||
}
|
||||
|
||||
echo "start building bot"
|
||||
cd "./bot" || exit 1
|
||||
REPO="git.hhhammer.de/hamburghammer/dchat/bot"
|
||||
TITLE="dchat-bot"
|
||||
DESCRIPTION="A Discord bot to chat with ChatGPT from OpenAI"
|
||||
DOCKER_BUILD_ARGS="--target bot"
|
||||
build
|
||||
cd ..
|
||||
|
||||
echo "start building web"
|
||||
cd "./web" || exit 1
|
||||
REPO="git.hhhammer.de/hamburghammer/dchat/web"
|
||||
TITLE="dchat-web"
|
||||
DESCRIPTION="A web API and UI for the dchat-bot configuration"
|
||||
DOCKER_BUILD_ARGS="--target web"
|
||||
build
|
||||
cd ..
|
||||
|
||||
echo "start building migration"
|
||||
cd "./migration" || exit 1
|
||||
REPO="git.hhhammer.de/hamburghammer/dchat/migration"
|
||||
TITLE="dchat-migration"
|
||||
DESCRIPTION="A migration tool for the dchat database"
|
||||
DOCKER_BUILD_ARGS="--target migration"
|
||||
build
|
||||
cd ..
|
||||
|
|
12
web/src/ui/.containerignore
Normal file
12
web/src/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/
|
11
web/src/ui/Caddyfile
Normal file
11
web/src/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
web/src/ui/Containerfile
Normal file
16
web/src/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"]
|
Loading…
Reference in a new issue