I am testing out some migration in Maven from a Spotify dockerfile plugin with Fabric8 to just using Eclipse's JKube plugin. I have been hitting errors with what I thought would be a simple enough build using a Dockerfile.
The POM config is like so:
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>1.5.1</version>
<configuration>
<images>
<image>
<name>${docker.image.prefix}/${docker.image.name}</name>
<build>
<dockerFile>${project.basedir}/Dockerfile</dockerFile>
</build>
</image>
</images>
</configuration>
</plugin>
The Dockerfile is (per config above) in the root of the project. It is very simple
FROM adoptopenjdk/openjdk11-openj9:x86_64-ubi-jre-11.0.12_7_openj9-0.27.0
ARG JAR_FILE
ADD target/${JAR_FILE} microservice.jar
ENTRYPOINT ["java", "-jar", "microservice.jar"]
Running mvn clean install k8s:build
ends with the following error message:
[INFO] --- kubernetes-maven-plugin:1.5.1:build (default-cli) @ persistence-svc ---
[INFO] k8s: Running in Kubernetes mode
[INFO] k8s: Building Docker image in Kubernetes mode
[ERROR] k8s: Failed to execute the build [Error while trying to build the image:<PROJ>\target\docker\<PREFIX>\<IMAGE>\build\maven\.git\objects\pack\pack-c35818936460f0bb0c1b903466f7bf1a17f22cc8.idx]
I am not sure what I am missing. I tried to add a jKube ignore file but that made no difference.
Any pointers would be much appreciated.
Looks like I was on the correct track with the ignore file. The syntax I had was incorrect. I had just
.git/
and needed.git/**
.It seems a little crazy that this should cause problems. Anyways I am sure there is a nicer solution overall but this gets me going without changing anything other than the plugins.
EDIT:
Indeed there is a better way for my use-case. Use
.jkube-dockerinclude
instead. Example here.