简体   繁体   English

在进行 docker-compose build 时遇到 Build 失败问题?

[英]While doing docker-compose build getting Build failure issue?

FROM java:8
FROM maven:alpine

WORKDIR /app
COPY pom.xml /app
RUN mvn clean
RUN mvn compile
RUN mvn install

COPY . /app
RUN mvn clean install
ENTRYPOINT ["java", "-jar", "/target/Brabo-Asset-Service-Web-0.0.1-SNAPSHOT-spring-boot.jar"]

Getting this error:收到此错误:

java: /app/src/main/java (add: main, clean: false, plugin: null, outputOptions: null)
[INFO]     grpc-java: /app/src/main/java (add: main, clean: false, plugin: null, outputOptions: null)
[INFO] Resolving artifact: io.grpc:protoc-gen-grpc-java:1.15.0, platform: linux-x86_64
[INFO]     Processing (java): NodeLevelService.proto
protoc-jar: executing: [/root/protocjar8340208475023305576/bin/protoc.exe, -I/tmp/protocjar1489995214004248376/include, -I/app/src/main/resources, --java_out=/app/src/main/java, /app/src/main/resources/NodeLevelService.proto]
protoc-jar: caught exception, retrying: java.io.IOException: Cannot run program "/root/protocjar8340208475023305576/bin/protoc.exe": error=2, No such file or directory
protoc-jar: executing: [/root/protocjar8340208475023305576/bin/protoc.exe, -I/tmp/protocjar1489995214004248376/include, -I/app/src/main/resources, --java_out=/app/src/main/java, /app/src/main/resources/NodeLevelService.proto]
protoc-jar: caught exception, retrying: java.io.IOException: Cannot run program "/root/protocjar8340208475023305576/bin/protoc.exe": error=2, No such file or directory
protoc-jar: executing: [/root/protocjar8340208475023305576/bin/protoc.exe, -I/tmp/protocjar1489995214004248376/include, -I/app/src/main/resources, --java_out=/app/src/main/java, /app/src/main/resources/NodeLevelService.proto]

I would agree with @stefano in regards to looking into doing a multistage build, but essentially your specific is issue is due to the fact that you are running a maven build without including/copying your source code first, so I believe your Dockerfile should look something like so:我同意@stefano 关于进行多阶段构建的看法,但本质上您的具体问题是由于您正在运行 maven 构建而没有首先包含/复制您的源代码,所以我相信您的 Dockerfile 应该看起来像这样:

FROM maven:alpine

WORKDIR /app
COPY . /app
RUN mvn clean install
ENTRYPOINT ["java", "-jar", "/target/Brabo-Asset-Service-Web-0.0.1-SNAPSHOT-spring-boot.jar"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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