]> juplo.de Git - demos/kafka/training/commitdiff
refactor: Docker-Build auf bootBuildImage (Cloud Native Buildpacks) umstellen consumer/spring-consumer--claude-5
authorKai Moritz <kai.milan.moritz@googlemail.com>
Fri, 22 May 2026 12:41:23 +0000 (12:41 +0000)
committerKai Moritz <kai.milan.moritz@googlemail.com>
Fri, 29 May 2026 20:32:16 +0000 (20:32 +0000)
Maven nutzte das io.fabric8:docker-maven-plugin, Gradle kopierte das JAR
in ein target/-Verzeichnis für dasselbe Dockerfile.

Beide Build-Systeme nutzen jetzt bootBuildImage, das über Cloud Native
Buildpacks direkt aus dem Spring Boot Plugin heraus ein OCI-Image erzeugt:

  Maven:  mvn spring-boot:build-image
  Gradle: ./gradlew bootBuildImage

Das jib-maven-plugin (durch Rebase aus grundlagen vererbt) entfällt zugunsten
des Spring-Boot-eigenen build-image-Ziels.

Außerdem: springBoot { buildInfo() } in Gradle ergänzt, analog zum
build-info-Goal des spring-boot-maven-plugin (bereits in Maven konfiguriert).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
build.gradle
pom.xml

index ea7ba48a405c98c87feec76b1e3e249ff4d29d6b..73b76a85bdbd4060b35e4ee23bb9cdd4684cb163 100644 (file)
@@ -3,7 +3,6 @@ plugins {
        id 'org.springframework.boot' version '4.0.6'
        id 'io.spring.dependency-management' version '1.1.7'
        id 'com.gorylenko.gradle-git-properties' version '2.4.2'
-       id 'com.google.cloud.tools.jib' version '3.4.5'
 }
 
 group = 'de.juplo.kafka'
@@ -46,12 +45,10 @@ tasks.named('test') {
        useJUnitPlatform()
 }
 
-tasks.named('test') {
-       useJUnitPlatform()
+springBoot {
+       buildInfo()
 }
 
-jib {
-       from { image = 'eclipse-temurin:21-jre' }
-       to { image = "juplo/${project.name}:${project.version}" }
-       container { mainClass = 'de.juplo.kafka.ExampleConsumer' }
+bootBuildImage {
+       imageName = "juplo/${project.name}:${project.version}"
 }
diff --git a/pom.xml b/pom.xml
index 5f6f9ee598b484b10390dce70c6603563d6784da..8426214747cc6dd73ab4ac78333bb8cbf8393e0e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
       <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
+        <configuration>
+          <image>
+            <name>juplo/${project.artifactId}:${project.version}</name>
+          </image>
+        </configuration>
         <executions>
           <execution>
             <goals>
         <groupId>pl.project13.maven</groupId>
         <artifactId>git-commit-id-plugin</artifactId>
       </plugin>
-      <plugin>
-        <groupId>com.google.cloud.tools</groupId>
-        <artifactId>jib-maven-plugin</artifactId>
-        <version>3.4.5</version>
-        <configuration>
-          <from>
-            <image>eclipse-temurin:21-jre</image>
-          </from>
-          <to>
-            <image>juplo/${project.artifactId}:${project.version}</image>
-          </to>
-          <container>
-            <mainClass>de.juplo.kafka.ExampleConsumer</mainClass>
-          </container>
-        </configuration>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>
-              <goal>dockerBuild</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
     </plugins>
   </build>