Simon Wick
Simon Wick

Reputation: 281

Quarkus native build with Mandrel

I'm trying to build Quarkus in native mode with Mandrel as described here: https://quarkus.io/guides/building-native-image#container-runtime

Due to limitations in my CI-pipeline, i need to do this manually with a multi-stage docker-build: https://quarkus.io/guides/building-native-image#using-a-multi-stage-docker-build

But now I don't know what to change in the Dockerfile, if I want to use Mandrel-image:

## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/centos-quarkus-maven:20.1.0-java11 AS build
COPY pom.xml /usr/src/app/
RUN mvn -f /usr/src/app/pom.xml -B de.qaware.maven:go-offline-maven-plugin:1.2.5:resolve-dependencies
COPY src /usr/src/app/src
USER root
RUN chown -R quarkus /usr/src/app
USER quarkus
RUN mvn -f /usr/src/app/pom.xml -Pnative clean package

## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY --from=build /usr/src/app/target/*-runner /work/application

# set up permissions for user `1001`
RUN chmod 775 /work /work/application \
  && chown -R 1001 /work \
  && chmod -R "g+rwX" /work \
  && chown -R 1001:root /work

EXPOSE 8080
USER 1001

CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

I'm sure it must be very simple, but I don't get it at the moment. Any suggestions?

Upvotes: 1

Views: 927

Answers (1)

Rohit Sharma
Rohit Sharma

Reputation: 1

This works to build with gradle

## Stage 1 : build with gradle builder image with native capabilities

FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17 AS build
USER root
RUN microdnf install findutils
COPY --chown=quarkus:quarkus gradlew /code/gradlew
COPY --chown=quarkus:quarkus gradle /code/gradle
COPY --chown=quarkus:quarkus build.gradle /code/
COPY --chown=quarkus:quarkus gradle.properties /code/
COPY --chown=quarkus:quarkus settings.gradle /code/
USER quarkus
WORKDIR /code
COPY src /code/src
RUN ./gradlew build -x test -Dquarkus.package.type=native

## Stage 2 : create the docker final image

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8
WORKDIR /work/
RUN chown 1001 /work \
    && chmod "g+rwX" /work \
    && chown 1001:root /work
COPY --chown=1001:root --from=build /code/build/*-runner /work/application

EXPOSE 8080
USER 1001

ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]

Upvotes: 0

Related Questions