I'm trying to use JKube for building and deploying APIs to my K8S cluster but when I do mvn k8s:build
I'm getting this error :
[INFO] --- kubernetes-maven-plugin:1.1.1:build (default-cli) @ trips-api ---
[INFO] k8s: Running in Kubernetes mode
[INFO] k8s: Building Docker image in Kubernetes mode
[INFO] k8s: [carpooling/trips-api:latest]: Created docker-build.tar in 2 seconds
[ERROR] k8s: Failed to execute the build [Error while trying to build the image: Unable to build image [carpooling/trips-api:latest] : "COPY failed: no source files were specified" ]
This is the content of my Dockerfile
:
FROM adoptopenjdk/openjdk11:latest
VOLUME /tmp
COPY target/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
NB: I'm ensuring that under my target/ directory I have the right jar file.
Does anyone have an idea about why I'm getting this error ?
Eclipse JKube has an assembly mechanism for adding files to your container images. When using zero configuration Dockerfile mode, assembly name is set to
maven
. You would need to prefix your project files withmaven
to be able to access it. So your Dockerfile should look like this:I tested this with a simple demo project with your Dockerfile contents: https://github.com/r0haaaan/eclipse-jkube-spring-boot-simple-dockerfile and it seemed to work okay for me.