quarkusio / quarkus

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

Provide Gradle GraalVM compatible builder image #6513

Closed Meemaw closed 4 years ago

Meemaw commented 4 years ago

Description In creating-a-container-with-a-multi-stage-docker-build guide there is a Maven docker base image with GraalVM capabilities.

It would be nice if there was one for projects using Gradle as well.

geoand commented 4 years ago

cc @cescoffier

cescoffier commented 4 years ago

Yes, that's relatively easy. We already have a module installing Gradle.

We just need:

1 - add Gradle to https://github.com/quarkusio/quarkus-images/blob/master/quarkus-maven-overrides-java8.yaml#L27 2 - Rename the image 3 - Update the documentation

The hardest, as usual, would be to find the right name for this image...

gastaldi commented 4 years ago

The hardest, as usual, would be to find the right name for this image...

centos-quarkus-gradle?

cescoffier commented 4 years ago

The same image would provide maven and gradle.

gastaldi commented 4 years ago

Maybe something like centos-quarkus-builder since it's meant to be used to build the app :)

gsmet commented 4 years ago

@fmhwong maybe you could have a look at that one too?

fmhwong commented 4 years ago

@cescoffier Do you have a preference of making a copy of quarkus-maven-overrides-java8.yaml and quarkus-maven-overrides-java11.yaml, making the changes in the copy and check them in OR modify the existing files?

k0staa commented 4 years ago

Maybe it will be useful to someone. This is a quick workaround

## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/centos-quarkus-maven:19.3.1-java11 AS build
COPY src /usr/src/app/src
COPY gradle /usr/src/app/gradle
COPY gradlew /usr/src/app
COPY build.gradle.kts /usr/src/app
COPY settings.gradle.kts /usr/src/app
COPY gradle.properties /usr/src/app
USER root
RUN chown -R quarkus /usr/src/app
USER quarkus
WORKDIR /usr/src/app/
RUN ./gradlew clean build -Dquarkus.package.type=native

## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY --from=build /usr/src/app/build/*-runner /work/application
RUN chmod 775 /work
EXPOSE 8080
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

One thing. I use Kotlin in Gradle configuration so if you don't use Kotlin, remove extensions in build.gradle.kts and settings.gradle.kts files.

gastaldi commented 4 years ago

@k0staa we're deprecating gradle buildNative in favor of gradle build -Dquarkus.package.type=native. See #8325 for more details

k0staa commented 4 years ago

@k0staa we're deprecating gradle buildNative in favor of gradle build -Dquarkus.package.type=native. See #8325 for more details

Thanks @gastaldi . I edited my post and also I change build command in my project.