From b1ac0f1ab7d11b08ab51612db0d00f2d1ff5a27f Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Tue, 7 Nov 2023 14:09:51 -0300 Subject: [PATCH] fix: add architecture compatibility flag to native build (#131) * fix: add architecture compatibility flag to native build * ci: wrong place for the parameter * ci: remove duplication of additional build arg * ci: update to native arch for better compatibility * ci: march compatibility * feat: downgrade java version to 17 --- backend/Dockerfile | 32 +++++++++++-------- backend/pom.xml | 4 +-- .../src/main/resources/application.properties | 2 +- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 41a992fd..06bc6b52 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,21 +1,27 @@ -# Quarkus Images -# https://github.com/quarkusio/quarkus-images +### Builder +FROM ghcr.io/graalvm/native-image:ol8-java17-22 AS build -# "Provides the native-image executable. Used by the Maven and Gradle plugin from Quarkus to build linux64 executables" -FROM quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:jdk-21 AS build +# Copy +WORKDIR /app +COPY pom.xml mvnw ./ +COPY src ./src +COPY .mvn/ ./.mvn -# Image defaults to /project; copy controlled by .dockerignore -COPY --chown=quarkus:quarkus . ./ +# Build RUN ./mvnw package -Pnative -DskipTests -# "A base image to run Quarkus native application using UBI Micro" -FROM quay.io/quarkus/quarkus-micro-image:2.0 +### Deployer +FROM gcr.io/distroless/java-base:nonroot AS deploy +ARG PORT=8080 + +# Copy +WORKDIR /app +COPY --from=build /app/target/results ./results # Port and health check -EXPOSE 8080 -HEALTHCHECK --interval=300s --timeout=3s CMD curl -f http://localhost:8080 +USER 1001 +EXPOSE ${PORT} +HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"' # Startup -COPY --chown=1001:root --from=build /project/target/results /app -USER 1001 -CMD ["/app", "-Dquarkus.http.host=0.0.0.0"] +ENTRYPOINT ["/app/results"] diff --git a/backend/pom.xml b/backend/pom.xml index cb32f108..17e7455d 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -23,8 +23,8 @@ - 21 - 21 + 17 + 17 UTF-8 UTF-8 true diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index e106571a..12a2b9b0 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -11,7 +11,7 @@ management.endpoint.health.show-details = always springdoc.enable-native-support = true # https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.2 -quarkus.native.additional-build-args=-march=x86-64-v2 +quarkus.native.additional-build-args=-march=native # Database, and JPA spring.datasource.driver-class-name = org.postgresql.Driver