Compare commits

..

No commits in common. "7171b8905a525d29f735d8bd90ff73a243c4c8ad" and "95cb36d6ed7d7fe970d02efd82c9be256494e536" have entirely different histories.

7 changed files with 52 additions and 105 deletions

View file

@ -1,27 +0,0 @@
matrix:
platform:
- linux/amd64
- linux/arm64
TARGET:
- bot
- web
- migration
platform: ${platform}
when:
branch: main
pipeline:
build:
image: woodpeckerci/plugin-docker-buildx
group: build
settings:
registry: git.hhhammer.de
username: ci
password:
from_secret: docker_token
dockerfile: Dockerfile
target: ${TARGET}
repo: git.hhhammer.de/hamburghammer/dchat/${TARGET}
tags: latest
pull_image: false

43
Containerfile Normal file
View file

@ -0,0 +1,43 @@
# 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"]

View file

@ -1,65 +0,0 @@
# syntax=docker/dockerfile:1
ARG MAVEN_CLI_OPTS="--batch-mode --no-transfer-progress -Dmaven.test.skip"
# Copy all project files
FROM docker.io/maven:3.9-eclipse-temurin-20 AS setup
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 --mount=type=cache,target=/root/.m2/ \
mvn ${MAVEN_CLI_OPTS} -pl db -am dependency:go-offline
# Install the shared libraries in the local Maven repo (`.m2`)
# This will also install the `root` module.
# Build db dependency
FROM setup AS db-build
COPY db db
RUN --mount=type=cache,target=/root/.m2/ \
mvn ${MAVEN_CLI_OPTS} -pl db -am install
# Resolve dependencies for modules without dependencies to each other
RUN --mount=type=cache,target=/root/.m2/ \
mvn ${MAVEN_CLI_OPTS} dependency:go-offline
# Build modules
FROM db-build AS web-build
COPY web web
RUN --mount=type=cache,target=/root/.m2/ \
--mount=type=cache,target=/app/web/src/ui/dist/ \
--mount=type=cache,target=/app/web/src/ui/node/ \
--mount=type=cache,target=/app/web/src/ui/node_modules/ \
mvn ${MAVEN_CLI_OPTS} -pl web package
FROM db-build AS bot-build
COPY bot bot
RUN --mount=type=cache,target=/root/.m2/ \
mvn ${MAVEN_CLI_OPTS} -pl bot package
FROM db-build AS migration-build
COPY migration migration
RUN --mount=type=cache,target=/root/.m2/ \
mvn ${MAVEN_CLI_OPTS} -pl migration package
# Create final web
FROM docker.io/eclipse-temurin:20-jdk-jammy AS web
WORKDIR /app
COPY --from=web-build /app/web/target/web-*-fat.jar /app/web.jar
EXPOSE 8080
CMD ["java", "-jar", "/app/web.jar"]
# Create final migration
FROM docker.io/eclipse-temurin:20-jdk-jammy AS migration
WORKDIR /app
COPY --from=migration-build /app/migration/target/migration-*-fat.jar /app/migration.jar
CMD ["java", "-jar", "/app/migration.jar"]
# Create final bot
FROM docker.io/eclipse-temurin:20-jdk-jammy AS bot
WORKDIR /app
COPY --from=bot-build /app/bot/target/bot-*-fat.jar /app/bot.jar
CMD ["java", "-jar", "/app/bot.jar"]

View file

@ -9,17 +9,10 @@ build() {
REVISION=$(git rev-parse HEAD) REVISION=$(git rev-parse HEAD)
IMAGE_LATEST="${REPO}:latest" IMAGE_LATEST="${REPO}:latest"
if [ "$PUSH_LATEST" == "1" ]; then
DOCKER_BUILD_ARGS="$DOCKER_BUILD_ARGS --push"
fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
docker buildx build \ podman build \
$DOCKER_BUILD_ARGS \ $DOCKER_BUILD_ARGS \
-t $IMAGE_LATEST \ -t $IMAGE_LATEST \
--file Containerfile \
--platform linux/amd64,linux/arm64 \
--label "org.opencontainers.image.revision=${REVISION}" \ --label "org.opencontainers.image.revision=${REVISION}" \
--label "org.opencontainers.image.version=${TAG}" \ --label "org.opencontainers.image.version=${TAG}" \
--label "org.opencontainers.image.authors=${AUTHORS}" \ --label "org.opencontainers.image.authors=${AUTHORS}" \
@ -30,6 +23,9 @@ build() {
--label "org.opencontainers.image.description=${DESCRIPTION}" \ --label "org.opencontainers.image.description=${DESCRIPTION}" \
. || exit $? . || exit $?
if [ "$PUSH_LATEST" == "1" ]; then
podman push "${IMAGE_LATEST}"
fi
} }
echo "start building bot" echo "start building bot"

View file

@ -6,7 +6,7 @@ services:
env_file: env_file:
- .env - .env
build: build:
dockerfile: Dockerfile dockerfile: Containerfile
context: . context: .
target: bot target: bot
restart: unless-stopped restart: unless-stopped
@ -22,7 +22,7 @@ services:
env_file: env_file:
- .env - .env
build: build:
dockerfile: Dockerfile dockerfile: Containerfile
context: . context: .
target: web target: web
restart: unless-stopped restart: unless-stopped
@ -38,7 +38,7 @@ services:
env_file: env_file:
- .env - .env
build: build:
dockerfile: Dockerfile dockerfile: Containerfile
context: . context: .
target: migration target: migration
user: 1000:1000 user: 1000:1000

View file

@ -27,8 +27,8 @@
</licenses> </licenses>
<properties> <properties>
<maven.compiler.source>20</maven.compiler.source> <maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target> <maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.15.1</jackson.version> <jackson.version>2.15.1</jackson.version>
</properties> </properties>