I'm trying to use Skaffold, Dekorate and Spring Boot.
I can't find any examples using the new buildpack feature of Spring Boot 2.3+
apiVersion: skaffold/v2beta9
kind: Config
metadata:
name: tellus-upgrade
build:
artifacts:
- image: tellus-admin
custom:
buildCommand: ./mvnw -pl tellus-admin org.springframework.boot:spring-boot-maven-plugin:2.4.0:build-image -Dspring-boot.build-image.imageName=$IMAGE -Drevision=dev-SNAPSHOT -DskipTests=true
dependencies:
paths:
- tellus-admin/src
- tellus-admin/pom.xml
- image: tellus-config-server
custom:
buildCommand: ./mvnw -pl tellus-config-server org.springframework.boot:spring-boot-maven-plugin:2.4.0:build-image -Dspring-boot.build-image.imageName=$IMAGE -Drevision=dev-SNAPSHOT -DskipTests=true
dependencies:
paths:
- tellus-config-server/src
- tellus-config-server/pom.xml
deploy:
kubectl:
manifests:
- kubernetes/defaults.yml
- kubernetes/db/kubernetes.yml
- kubernetes/dev/dnsutils.yml
- kubernetes/kafka-connect/kubernetes.yml
- tellus-admin/target/classes/META-INF/dekorate/kubernetes.yml
- tellus-config-server/target/classes/META-INF/dekorate/kubernetes.yml
When I run skaffold dev I get the error: exiting dev mode because first build failed: the custom script didn't produce an image with tag [tellus-config-server:RELEASE_2020_2_0-226-g9be76a373-dirty]
However from the logs it looks like the image was built...
[INFO] Successfully built image 'docker.io/library/tellus-config-server:RELEASE_2020_2_0-226-g9be76a373-dirty'
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.004 s
[INFO] Finished at: 2020-11-15T22:31:59+11:00
[INFO] ------------------------------------------------------------------------
Building [tellus-admin]...
exiting dev mode because first build failed: the custom script didn't produce an image with tag [tellus-config-server:RELEASE_2020_2_0-226-g9be76a373-dirty]
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/sh
set -e
cd "$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.