当前位置: 首页 > 知识库问答 >
问题:

构建Quarkus本地问题

淳于玺
2023-03-14

我正在尝试构建Quarkus本机应用程序,但在Docker内部构建过程中,我被拒绝访问。我在跟踪这个医生

Dockerfile:

# Limit memory of build
ARG BUILD_MEMORY=4g

## Stage 1: build native sources
FROM gradle:7.3-jdk11 AS gradle-build
COPY --chown=gradle:gradle build.gradle /code/
COPY --chown=gradle:gradle settings.gradle /code/
COPY --chown=gradle:gradle gradle.properties /code/

USER gradle
WORKDIR /code
COPY --chown=gradle:gradle src /code/src

RUN gradle clean assemble -Dquarkus.package.type=native-sources


## Stage 2: build quarkus-native
FROM quay.io/quarkus/ubi-quarkus-mandrel:21.2-java11 AS native-build
ARG BUILD_MEMORY
WORKDIR /build
COPY --from=gradle-build /code/build/native-sources /build/

RUN native-image $(cat native-image.args) -J-Xmx$BUILD_MEMORY


## Stage 3 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5
WORKDIR /work/
COPY --from=native-build /build/*-runner /work/application
COPY docker-entrypoint.sh /work/entrypoint.sh
RUN chmod 775 /work && chmod 755 /work/entrypoint.sh
EXPOSE 8080
ENTRYPOINT [ "/work/entrypoint.sh" ]
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

错误:

Step 14/22 : RUN native-image $(cat native-image.args) -J-Xmx$BUILD_MEMORY
 ---> Running in 5bda535214b1
[app-1.0.0-runner:73]    classlist:   3,624.96 ms,  1.20 GB
...
[app-1.0.0-runner:73]        write:     692.61 ms,  5.85 GB
Fatal error:java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1

Linker command executed:
/usr/bin/gcc -z noexecstack -Wl,--gc-sections -Wl,--dynamic-list -Wl,/tmp/SVM-4069521364666676056/exported_symbols.list -Wl,--exclude-libs,ALL -Wl,-x -o /build/app-1.0.0-runner app-1.0.0-runner.o /opt/mandrel/lib/svm/clibraries/linux-amd64/liblibchelper.a /opt/mandrel/lib/static/linux-amd64/glibc/libawt_headless.a /opt/mandrel/lib/static/linux-amd64/glibc/libawt.a /opt/mandrel/lib/static/linux-amd64/glibc/libnet.a /opt/mandrel/lib/static/linux-amd64/glibc/libextnet.a /opt/mandrel/lib/static/linux-amd64/glibc/libnio.a /opt/mandrel/lib/static/linux-amd64/glibc/libjava.a /opt/mandrel/lib/static/linux-amd64/glibc/libfdlibm.a /opt/mandrel/lib/static/linux-amd64/glibc/libsunec.a /opt/mandrel/lib/static/linux-amd64/glibc/libzip.a /opt/mandrel/lib/svm/clibraries/linux-amd64/libjvm.a -v -L/tmp/SVM-4069521364666676056 -L/opt/mandrel/lib/static/linux-amd64/glibc -L/opt/mandrel/lib/svm/clibraries/linux-amd64 -lstdc++ -lstdc++ -lm -lpthread -ldl -lz -lrt

Linker command output:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC) 
...
/usr/bin/ld: cannot open output file /build/app-1.0.0-runner: Permission denied
collect2: error: ld returned 1 exit status
    ...
[app-1.0.0-runner:73]      [total]: 122,312.28 ms,  5.85 GB
Exception in thread "main" jdk.vm.ci.common.JVMCIError: java.nio.file.AccessDeniedException: /build/app-1.0.0-runner.build_artifacts.txt
Error: Image build request failed with exit status 1

似乎本机映像命令不会创建app-1.0.0-runner。构建人工制品。txt。

你能帮我一下吗?

顺致敬意,

共有1个答案

壤驷经国
2023-03-14

该问题是由复制指令之前的WORKDIR条款引起的。

固定Dockerfile:

# Limit memory of build
ARG BUILD_MEMORY=4g

## Stage 1: build native sources
FROM gradle:7.3-jdk11 AS gradle-build
COPY --chown=gradle:gradle build.gradle /code/
COPY --chown=gradle:gradle settings.gradle /code/
COPY --chown=gradle:gradle gradle.properties /code/

USER gradle
WORKDIR /code
COPY --chown=gradle:gradle src /code/src

RUN gradle clean assemble -Dquarkus.package.type=native-sources


## Stage 2: build quarkus-native
FROM quay.io/quarkus/ubi-quarkus-mandrel:21.3-java11 AS native-build
ARG BUILD_MEMORY
COPY --chown=quarkus:quarkus --from=gradle-build /code/build/native-sources /build
USER quarkus
WORKDIR /build

RUN native-image $(cat native-image.args) -J-Xmx$BUILD_MEMORY


## Stage 3 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5
WORKDIR /work/
COPY --from=native-build /build/*-runner /work/application
COPY docker-entrypoint.sh /work/entrypoint.sh
RUN chmod 775 /work && chmod 755 /work/entrypoint.sh
EXPOSE 8080
ENTRYPOINT [ "/work/entrypoint.sh" ]
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
 类似资料:
  • 不确定我错过了什么?在阅读了多个博客和StackOverflow问题后,我尝试将内存增加到Xmx12G,但没有成功。我不断得到msg来增加内存。最近有没有人面临这个问题,它已经解决了吗?这只是直接从夸克网站下载的普通应用程序。

  • 有可能在Java 16下构建本机Quarkus映像吗?没有找到任何操作说明。 不知何故,这应该是可能的,因为Oracle发布了对Java16的GraalVM支持(https://www.graalvm.org/release-notes/21_1/)

  • 我有以下简化设置: 4)应用程序.属性 当我使用本机maven配置文件(mvn clean package-pnative)运行该文件时,我得到: 使用--report-unsupport-elements-at-runtime运行它也没有太大帮助。当我删除MyEntity类时,它在Mac+GRAALVM-CE-Java11-20.0.0上成功地编译为本机可执行文件

  • 我正在尝试使用Github自托管运行程序为我的qukus应用程序构建原生映像。 这对我来说在Github托管的跑步者上非常有用,但我想在自托管的跑步者上这样做,这样我们就不会浪费Github的预算。 当我更新我的工作流程以使用自我托管的跑步者时,我开始遇到这个奇怪的异常。 我使用的是GraalVM 22.0.0.2、Java 11.0.14、Maven 3.8.4和Quarkus 2.7.5 我尝

  • 我遵循了构建quarkus本机可执行文件的步骤。 1.引导项目: 2.在minishift中使用docker 3.生成包: 失败,错误跟踪如下: 根据要求,树输出如下所示: