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