Compare commits

...

27 commits

Author SHA1 Message Date
7171b8905a ci: Run only on main branche
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-07-27 01:04:49 +02:00
13693bf7a7 ci: Remove matrix ref in step name
It doesn't work -_-
2023-07-27 01:03:17 +02:00
b36b087302 build: Rename Containerfile to Dockerfile
All checks were successful
ci/woodpecker/push/build Pipeline was successful
We are now using Docker specific build instruction and using a generic
name doesn't make any sense now.
2023-07-27 00:50:50 +02:00
4b67b605f3 ci: Try to use native agents for each arch
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-07-27 00:38:17 +02:00
4762911c8c build: Fix MAVEN_CLI_OPTS argument
Some checks are pending
ci/woodpecker/push/build Pipeline is pending
2023-07-27 00:28:04 +02:00
1bcc9af5ba build: Improve build caching and layering
Some checks failed
ci/woodpecker/push/build Pipeline failed
2023-07-27 00:20:58 +02:00
eef6b98171 build: Update java to version 20
Some checks failed
ci/woodpecker/push/build Pipeline failed
2023-07-26 19:45:33 +02:00
ab8b65f099 build: Skip test compilation/execution 2023-07-26 19:35:55 +02:00
d87af982f7 build/ci: Remove arm platform version
Some checks failed
ci/woodpecker/push/build Pipeline failed
2023-07-26 19:10:42 +02:00
aae16b0e88 build: Change to Docker with Buildx to build multi arch images
Some checks failed
ci/woodpecker/push/build Pipeline failed
ci/woodpecker/push/build/1 Pipeline is pending
ci/woodpecker/push/build/2 Pipeline is pending
ci/woodpecker/push/build/3 Pipeline is pending
The creation of a builder context is not automated. You might need to
create your own before running the script.

```
docker buildx create --name dchat-builder --use --bootstrap
```
2023-07-19 11:52:44 +02:00
b5ebeabec4 ci: Disable pulling images on each run
Some checks failed
ci/woodpecker/push/build Pipeline failed
This should prevent running into rate limits from DockerHub.
2023-07-18 20:24:53 +02:00
0d09f1d3b4 ci: Enable parallelization 2023-07-18 20:22:49 +02:00
616bcf1f18 ci: Simplify generating all builds
Some checks failed
ci/woodpecker/push/build Pipeline failed
2023-07-18 20:06:58 +02:00
8f2cdf8bad ci: Remove platform constrain for builds
All checks were successful
ci/woodpecker/push/build-amd64 Pipeline was successful
ci/woodpecker/push/build-arm Pipeline was successful
2023-07-18 18:39:14 +02:00
2cefa95f6f ci: Change docker image to woodpeckers docker image with buildx support 2023-07-18 18:38:16 +02:00
1a130da1da ci: Change platform for arm builds to arm 2023-07-18 18:38:16 +02:00
ca6a913578 container: Add .dockerignore
Some checks failed
ci/woodpecker/push/build-amd64 Pipeline was successful
ci/woodpecker/push/build-arm Pipeline failed
We will use Docker as builder in the CI for now and Docker doesn't
understand .containerignore files...
2023-07-18 00:35:32 +02:00
e56e9d0ee3 ci: Change to docker plugin to build multi platform image 2023-07-18 00:34:36 +02:00
f7e8b2356f container: Switch from alpine to jammy as final base image
Eclipse doesn't provide arm64 builds of the alpine base image.
2023-07-17 00:39:32 +02:00
1a432e9f3d container: Further reduce build output 2023-07-17 00:38:59 +02:00
d4ca9336b4 ci: Switch back to previous docker password config
Some checks failed
ci/woodpecker/push/build-arm Pipeline is pending
ci/woodpecker/push/build-amd64 Pipeline failed
2023-07-16 21:49:14 +02:00
1d68948c5a container: Reduce maven output wihle building 2023-07-16 21:46:44 +02:00
db07e70679 ci: Specify Containerfile
Some checks failed
ci/woodpecker/push/build-arm Pipeline is pending
ci/woodpecker/push/build-amd64 Pipeline failed
2023-07-16 21:36:29 +02:00
0062491b2e ci: Fix when clause
Some checks failed
ci/woodpecker/push/build-arm Pipeline is pending
ci/woodpecker/push/build-amd64 Pipeline failed
2023-07-16 21:27:14 +02:00
de18f158aa ci: Fix image indentation 2023-07-16 21:21:11 +02:00
439f62c31f Add different method to provide Docker creds 2023-07-16 21:19:32 +02:00
cb42a9b2c2 Add Woodpecker CI config for building bot image 2023-07-16 21:11:59 +02:00
7 changed files with 105 additions and 52 deletions

27
.woodpecker/build.yml Normal file
View file

@ -0,0 +1,27 @@
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

View file

@ -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"]

65
Dockerfile Normal file
View file

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

View file

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

View file

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