quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.87k stars 2.71k forks source link

Quarkus with GRPC extension fails to build on Alpine Linux #42716

Open andreiyusupau opened 3 months ago

andreiyusupau commented 3 months ago

Describe the bug

I'm running into following exception when trying to run gradle build on simple Quarkus app using grpc plugin:

Task :quarkusGenerateCode
terminate called after throwing an instance of 'std::system_error'
what():  No error information
--grpc_out: protoc-gen-grpc: Plugin killed by signal 6.

Expected behavior

Like in Quarkus 3.10.0 project builds fine.

Actual behavior

In Quarkus 3.13.3 build fails.

How to Reproduce?

Create a sample app with grpc extension using gradle via https://code.quarkus.io. Put the following Dockerfile into a project folder and run docker build . :

FROM docker:27.1.2

RUN apk update
RUN apk upgrade
RUN apk add curl bash gcompat libstdc++
RUN apk add openjdk21
RUN apk add gradle
RUN curl -Ls https://sh.jbang.dev | bash -s - trust add https://repo1.maven.org/maven2/io/quarkus/quarkus-cli/
RUN curl -Ls https://sh.jbang.dev | bash -s - app install --fresh --force quarkus@quarkusio
COPY . .
RUN gradle build --no-daemon

CMD ["tail", "-f", "/dev/null"]

P.S. In reality I encounter this error when using Gitlab pipelines, this Dockerfile just emulates it's behavior.

Output of uname -a or ver

No response

Output of java -version

21.0.4

Quarkus version or git rev

3.13.3

Build tool (ie. output of mvnw --version or gradlew --version)

gradle 8.7

Additional information

I've checked this issue https://github.com/quarkusio/quarkus/issues/13773 and if it's bug with protoc versions like stated here any suggestions on fixing dependencies or using custom protoc would be also great :) Guide (https://quarkus.io/guides/grpc-getting-started) says about special property to specify custom protoc implementation -Dquarkus.grpc.protoc-path=/path/to/protoc., but I didn't understand if it suites for gradle or it's only solution for quarkus-maven-plugin.

quarkus-bot[bot] commented 3 months ago

/cc @alesj (grpc), @cescoffier (grpc), @maxandersen (jbang), @quarkusio/devtools (jbang)

cescoffier commented 3 months ago

Does protoc work on Alpline?

(In general, I do not recommend Alpine; UBI should work)

andreiyusupau commented 3 months ago

@cescoffier it worked fine with Quarkus 3.10.0. Also as I can see official Docker image has only Alpine-based distributions.

cescoffier commented 3 months ago

We had to update protoc because of CVE. The new version has new native dependencies. Try installing protoc directly and see if it works, I believe it won't.

andreiyusupau commented 3 months ago

I've updated my Dockerfile to use local protoc installation:

FROM docker:27.1.2

RUN apk update
RUN apk upgrade
RUN apk add curl bash
RUN apk add gradle
RUN apk add protoc
RUN curl -Ls https://sh.jbang.dev | bash -s - trust add https://repo1.maven.org/maven2/io/quarkus/quarkus-cli/
RUN curl -Ls https://sh.jbang.dev | bash -s - app install --fresh --force quarkus@quarkusio
COPY . .

RUN gradle build -Dquarkus.grpc.protoc-path=/usr/bin/protoc

CMD ["tail", "-f","/dev/null"]

But it seems that parameter -Dquarkus.grpc.protoc-path doesn't work, because I'm getting the following error:

84.53 > Task :quarkusGenerateCode
109.5 
109.5 /build/io.grpc-protoc-gen-grpc-java-linux-x86_64-exe: program not found or is not executable
109.5 Please specify a program using absolute path or make sure the program is available in your PATH system variable
109.5 --grpc_out: protoc-gen-grpc: Plugin failed with status code 1.
109.5 
109.5 > Task :quarkusGenerateCode FAILED
109.5 
109.5 FAILURE: Build failed with an exception.

Is there a way to specify local protoc to be used in gradle build process?

cescoffier commented 3 months ago

You need https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/1.38.0/.

andreiyusupau commented 3 months ago

Usage of https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/1.38.0/ (along with this plugin to execute the proto files compilation https://github.com/google/protobuf-gradle-plugin) together with with Quarkus leads to this issue: https://github.com/google/protobuf-gradle-plugin/issues/659

andreiyusupau commented 2 months ago

@cescoffier Could you suggest any solution to this problem? Moving away from alpine doesn't seem to be an option, because official docker images (including dind) are only alpine-based, and I need to dind to build Quarkus using Gitlab Pipelines (switching to jib doesn't help, it also requires docker to be installed on machine).

cescoffier commented 2 months ago

Unfortunately, you need to find which native libraries are required and not installed in your image. There are two native executables:

You can try to see which one does not work on a plain Alpine (make sure you download the correct OS/Arch version from https://repo1.maven.org/maven2/com/google/protobuf/protoc/4.28.2/ for the first one and https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/1.68.0/ for the second one).

My guess is a problem with the second one. If I print the loaded library on a plain run, I got:

dyld[12857]: <D778108D-DD45-3BFA-98CD-02AC813D31B3> /Users/clement/Development/quarkus/quarkus/integration-tests/grpc-plain-text-mutiny/target/io.grpc-protoc-gen-grpc-java-osx-aarch_64-exe
dyld[12857]: <69ECA28C-BFB7-35BF-AD4F-1BECE712D239> /usr/lib/libc++.1.dylib
dyld[12857]: <415DFD29-53FE-3E53-8B69-B2F8D55B211F> /usr/lib/libSystem.B.dylib
dyld[12857]: <BCFC9C6A-924D-307B-9F7A-6B8562660CC6> /usr/lib/libc++abi.dylib
dyld[12857]: <86EE6E4F-690E-3267-BEE3-9C35FAAFCFCF> /usr/lib/system/libcache.dylib
dyld[12857]: <1C4DFD8B-467F-33C7-86B7-1494CC327BEC> /usr/lib/system/libcommonCrypto.dylib
dyld[12857]: <980E1201-1AC6-33CC-BE3F-7A04A343CCA7> /usr/lib/system/libcompiler_rt.dylib
dyld[12857]: <D235F4EC-B34F-3A6A-81D4-08623EB495F5> /usr/lib/system/libcopyfile.dylib
dyld[12857]: <8740D9E3-987F-32FD-A60E-7888E233D4E3> /usr/lib/system/libcorecrypto.dylib
dyld[12857]: <FFB968B0-807C-38BF-AE61-50A96C8D310C> /usr/lib/system/libdispatch.dylib
dyld[12857]: <B8C581D4-18AA-3DAD-A222-8D32852BBF88> /usr/lib/system/libdyld.dylib
dyld[12857]: <66BD9187-4F1C-3387-B7F7-ED8844134D4C> /usr/lib/system/libkeymgr.dylib
dyld[12857]: <0BC74C54-2B95-39AC-B272-6F7C40DDD0AE> /usr/lib/system/libmacho.dylib
dyld[12857]: <ECFCF3A6-773A-371F-B26B-1378303F8167> /usr/lib/system/libquarantine.dylib
dyld[12857]: <4F7EA35D-44EA-3AEF-9274-75179D112EA1> /usr/lib/system/libremovefile.dylib
dyld[12857]: <56D16A01-A07D-3472-8EEF-461B5A55A8A5> /usr/lib/system/libsystem_asl.dylib
dyld[12857]: <E304A496-89FE-3656-8E95-7CB4CE44B418> /usr/lib/system/libsystem_blocks.dylib
dyld[12857]: <D7ACDB03-4453-3D57-9B53-9F338BCA635D> /usr/lib/system/libsystem_c.dylib
dyld[12857]: <C8DB633A-FFE8-387E-92E9-19E1203BA7A5> /usr/lib/system/libsystem_collections.dylib
dyld[12857]: <C6A1401B-C01A-39D0-92C6-7AFE23923CA8> /usr/lib/system/libsystem_configuration.dylib
dyld[12857]: <BAD20D87-F741-325C-94D4-2BCB47B6DEFA> /usr/lib/system/libsystem_containermanager.dylib
dyld[12857]: <E9A59C25-E344-3FDD-A8FA-54FBB4CE40E1> /usr/lib/system/libsystem_coreservices.dylib
dyld[12857]: <C1C6DCF6-7833-3562-9035-B1B8DE98DDDD> /usr/lib/system/libsystem_darwin.dylib
dyld[12857]: <DDF8B46A-E38C-32D1-8887-12903C89F39B> /usr/lib/system/libsystem_darwindirectory.dylib
dyld[12857]: <4EB6AF78-1332-32DB-B5FB-DC26A2494450> /usr/lib/system/libsystem_dnssd.dylib
dyld[12857]: <C71C0516-D101-36D8-B137-1A518C99B4BA> /usr/lib/system/libsystem_eligibility.dylib
dyld[12857]: <DB83A5B9-2219-32BC-8A13-D819353C2FAD> /usr/lib/system/libsystem_featureflags.dylib
dyld[12857]: <68CBC335-1E5D-3D55-BBE9-A50F1DB8BBE4> /usr/lib/system/libsystem_info.dylib
dyld[12857]: <F895A4E9-5569-3063-BE69-C282276053D2> /usr/lib/system/libsystem_m.dylib
dyld[12857]: <0D1B7CAD-F0B1-35F5-A5A1-71FCCC4A8C75> /usr/lib/system/libsystem_malloc.dylib
dyld[12857]: <604B29F0-6326-35B8-B583-67CF8DDF1022> /usr/lib/system/libsystem_networkextension.dylib
dyld[12857]: <3034009C-5DEB-376C-9BCD-6F730A2EC91E> /usr/lib/system/libsystem_notify.dylib
dyld[12857]: <1B2B0034-37B7-30CD-BFD6-E0556A314A8B> /usr/lib/system/libsystem_sandbox.dylib
dyld[12857]: <235D8EC2-B6DF-3C16-99FA-CBCB628D764B> /usr/lib/system/libsystem_sanitizers.dylib
dyld[12857]: <D595E8C1-3E84-3EF1-8B5C-FD2011661A0D> /usr/lib/system/libsystem_secinit.dylib
dyld[12857]: <54B50613-CC4B-3ACE-A9EC-919EA83D5E5F> /usr/lib/system/libsystem_kernel.dylib
dyld[12857]: <4EA5BBF7-8CE1-37AB-916B-D14FFD7D2B4B> /usr/lib/system/libsystem_platform.dylib
dyld[12857]: <D70DE43A-2804-340A-804C-5D316C1E013B> /usr/lib/system/libsystem_pthread.dylib
dyld[12857]: <35C05AC2-0348-3B5C-B3E4-E48B90CEAF6E> /usr/lib/system/libsystem_symptoms.dylib
dyld[12857]: <99CA3790-E29F-3272-9A76-07A8AF07384B> /usr/lib/system/libsystem_trace.dylib
dyld[12857]: <47B021E5-F67D-3895-9132-0BFC2B27AE4D> /usr/lib/system/libunwind.dylib
dyld[12857]: <DE6F07C9-7000-3DD2-A6E4-27A108381BCB> /usr/lib/system/libxpc.dylib
dyld[12857]: <752B00EA-A3EB-3ACE-AF8B-0F739F86CB6E> /usr/lib/libobjc.A.dylib
dyld[12857]: <D40E3914-099C-3FC6-940A-9FF789D809E6> /usr/lib/liboah.dylib

A few specific system libraries may not be present by default on Alpine. Remember that Alpine uses Musl and not the standard glibc (by default, I've seen Alpine variant with the glibc).

Can you try to create containers with just Alpine, these executables, and start them? Let's see what they say.

cescoffier commented 2 months ago

For the record, on Mac, there is no ldd :-( Thus, I had to create my own:

> DYLD_PRINT_LIBRARIES=1 DYLD_PRINT_LIBRARIES_POST_LAUNCH=1 DYLD_PRINT_RPATHS=1  ./io.grpc-protoc-gen-grpc-java-osx-aarch_64-exe