]> juplo.de Git - demos/kafka/training/commitdiff
refactor: Docker-Build auf bootBuildImage (Cloud Native Buildpacks) umstellen producer/spring-producer--claude-5
authorKai Moritz <kai.milan.moritz@googlemail.com>
Fri, 22 May 2026 12:40:13 +0000 (12:40 +0000)
committerKai Moritz <kai.milan.moritz@googlemail.com>
Fri, 29 May 2026 20:26:34 +0000 (20:26 +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

Vorteile:
- Kein Dockerfile nötig
- Beide Build-Systeme verwenden dieselbe Methode
- Image folgt automatisch Best Practices (non-root, layered JAR)
- jib-maven-plugin und gradle-git-properties waren bereits durch Rebase
  vorhanden; jib entfällt zugunsten des Spring-Boot-eigenen build-image

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 91b1a161ba02fcdd70aabaf07d3e9c5eaf07cc7d..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.ExampleProducer' }
+bootBuildImage {
+       imageName = "juplo/${project.name}:${project.version}"
 }
diff --git a/pom.xml b/pom.xml
index 3ab5c8c050e42bf5e2c3609408bdafe02c628759..d10f6b85cdef677f264455e8cb0ef605556df38d 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.ExampleProducer</mainClass>
-          </container>
-        </configuration>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>
-              <goal>dockerBuild</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
     </plugins>
   </build>