From 85b203fc892fadcacca8c17a501590556d173632 Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Mon, 25 Sep 2023 06:45:21 -0700 Subject: [PATCH] deps: quarkus graalvmce build base (#23) * deps: quarkus graalvmce build base * Chop down build * Comments and layout * Simplify Dockerfile, use .dockerignore, comments --- backend-java/.dockerignore | 7 +++++++ backend-java/Dockerfile | 34 ++++++++++++++++------------------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/backend-java/.dockerignore b/backend-java/.dockerignore index 90f0431..b60df1b 100644 --- a/backend-java/.dockerignore +++ b/backend-java/.dockerignore @@ -1 +1,8 @@ target/** +.dockerignore +.gitignore +Dockerfile +mvnw.cmd +*.yml +*.yaml +*.md diff --git a/backend-java/Dockerfile b/backend-java/Dockerfile index f078915..11a3092 100644 --- a/backend-java/Dockerfile +++ b/backend-java/Dockerfile @@ -1,23 +1,21 @@ -FROM quay.io/quarkus/ubi-quarkus-native-image:22.3.0-java17 AS build -COPY --chown=quarkus:quarkus mvnw /code/mvnw -COPY --chown=quarkus:quarkus .mvn /code/.mvn -COPY --chown=quarkus:quarkus pom.xml /code/ -USER quarkus -WORKDIR /code -RUN chmod +x mvnw -RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline -COPY src /code/src +# Quarkus Images +# https://github.com/quarkusio/quarkus-images + +# "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:22.3.3-java17 AS build + +# Image defaults to /project; copy controlled by .dockerignore +COPY --chown=quarkus:quarkus . ./ RUN ./mvnw package -Pnative -DskipTests -HEALTHCHECK --interval=300s --timeout=30s CMD ./mvnw --version || exit 1 -### + +# "A base image to run Quarkus native application using UBI Micro" FROM quay.io/quarkus/quarkus-micro-image:2.0 -WORKDIR /work/ -RUN chown 1001 /work \ - && chmod "g+rwX" /work \ - && chown 1001:root /work -COPY --chown=1001:root --from=build /code/target/*-runner /work/application +# Port and health check EXPOSE 3000 -USER 1001 HEALTHCHECK --interval=300s --timeout=3s CMD curl -f http://localhost:3000/ || exit 1 -CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] + +# Startup +COPY --chown=1001:root --from=build /project/target/*-runner /app +USER 1001 +CMD ["/app", "-Dquarkus.http.host=0.0.0.0"]