Google Cloud Platform pipeline/container builder issue building docker image using COPY or ADD command for Spring Boot Java Application

旧街凉风 提交于 2019-12-06 20:43:33

Looks like a problem with file paths.

Try the following updated Dockerfile, which explicitly sets the working directory. It also uses explicit file paths when copying the jar between images.

FROM maven:3.5-jdk-8-slim AS build
WORKDIR /home/app
COPY src     /home/app/src
COPY pom.xml /home/app
RUN mvn clean package

FROM openjdk:8-jre-slim
COPY --from=build /home/app/target/helloworld-0.0.1-SNAPSHOT.jar /usr/local/lib/helloworld.jar
EXPOSE 8081
ENTRYPOINT ["java","-jar","/usr/local/lib/helloworld.jar"]

Additional Notes:

  • See the related answer for a full example building a spring boot app
  • I've based the second stage on a JRE image. Reduces the size of the output image.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!