简体   繁体   中英

JKube maven plugin can't find jar file when building docker image using mvn k8s:build

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM