How do I use spring boot maven plugin build-image with skaffold and dekorate? How do I use spring boot maven plugin build-image with skaffold and dekorate? kubernetes kubernetes

How do I use spring boot maven plugin build-image with skaffold and dekorate?


The spring-boot-maven-plugin:build-image loads the image into your local Docker daemon, but does not push the image. I've never tried it, but you might be able to use the com.spotify:dockerfile-maven-plugin:push goal.

Update: here's a Skaffold custom build script that should do the right thing:

#!/bin/shset -ecd "$BUILD_CONTEXT"mvn -pl "$1" -Drevision=dev-SNAPSHOT -DskipTests=true \  org.springframework.boot:spring-boot-maven-plugin:build-image \  -Dspring-boot.build-image.imageName="$IMAGE"if [ "$PUSH_IMAGE" = true ]; then    docker push "$IMAGE"fi

You could save that to a file mvn-build-image.sh and then modify your skaffold.yaml like:

artifacts:- image: tellus-admin  custom:    buildCommand: ./mvn-build-image.sh tellus-admin 

You might want to look at the Skaffold's Jib integration to simplify this process.


If the problem is based on Paketo/spring-boot-maven-plugin only producing a local container image - and not pushing it as Brian de Alwis outlined - then the Image Publishing ability of the spring-boot-maven-plugin should do the trick. Therefore simply append the following to your mvn spring-boot:build-image command:

mvn spring-boot:build-image -Dspring-boot.build-image.publish=true

You can also configure the image name like this explicitely:

mvn spring-boot:build-image -Dspring-boot.build-image.imageName=docker.example.com/library/tellus-config-server:latest -Dspring-boot.build-image.publish=true

As the docs state you can also configure every aspect of image publishing in your pom.xml:

<plugin>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-maven-plugin</artifactId>    <configuration>        <image>            <name>docker.example.com/library/${project.artifactId}</name>            <publish>true</publish>        </image>        <docker>            <publishRegistry>                <username>user</username>                <password>secret</password>                <url>https://docker.example.com/v1/</url>                <email>user@example.com</email>            </publishRegistry>        </docker>    </configuration></plugin>

With that configuration in place you wouldn't even need to explicitely use the -Dspring-boot.build-image.publish=true parameter, since we configured <image><publish> to be true.

So no need to use Jib or custom build scripts. And there's even Cloud Native Buildpack support currently in beta for Skaffold - so that could be another option to have a look on (because the spring-boot-maven-plugin is also "only" an abstraction for the Cloud Native Buildpack / Paketo.io integration), if you'd like to switch to pack CLI.