0

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 ?

Ghassen
  • 591
  • 1
  • 15
  • 33
  • Hi, Plugin seems to be complaining for no deployment artifacts being present in `target/` directory. Are you sure you have done `mvn package` or `mvn clean install` for issuing `mvn k8s:build`? – Rohan Kumar Mar 15 '21 at 06:11
  • Would it be possible for you to share a reproducible project? Could you please join out chat https://gitter.im/eclipse/jkube – Rohan Kumar Mar 15 '21 at 08:14
  • @RohanKumar I verified that target/ was not empty. I just copied this thread into the discussion as you asked. How could I share a reproducible project ? Would you like to be added to my bitbucket ? – Ghassen Mar 15 '21 at 15:38
  • Np, let me try to prepare a reproducer and share it in case it's confidential – Rohan Kumar Mar 15 '21 at 16:56

1 Answers1

1

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 with maven to be able to access it. So your Dockerfile should look like this:

FROM adoptopenjdk/openjdk11:latest
VOLUME /tmp
COPY maven/target/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

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.

Rohan Kumar
  • 5,427
  • 8
  • 25
  • 40