From 792bb6e4762a6e36b022b4a85d7c7efcefc3e5bc Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 6 Oct 2022 22:29:15 +0200 Subject: [PATCH 1/8] change ip address --- src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 66fd4ea..8365c74 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -9,7 +9,7 @@ mp.jwt.token.cookie=jwt quarkus.datasource.db-kind = postgresql quarkus.datasource.username = toto quarkus.datasource.password = toto -quarkus.datasource.jdbc.url = jdbc:postgresql://db:5432/toto +quarkus.datasource.jdbc.url = jdbc:postgresql://51.222.107.37:54321/toto # drop and create the database at startup (use `update` to only update the schema) #quarkus.hibernate-orm.database.generation = drop-and-create quarkus.hibernate-orm.database.generation = update @@ -25,7 +25,7 @@ quarkus.mailer.password=aohrpmqvxldwyebs quarkus.mailer.mock=false -quarkus.redis.hosts=redis://redis:6379 +quarkus.redis.hosts=redis://51.222.107.37:63791 quarkus.http.cors=true quarkus.http.origins=http://localhost:8084 From ab1b3079f22d13ec936b4df37d98598effbbce7a Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Mon, 10 Oct 2022 23:55:18 +0200 Subject: [PATCH 2/8] change address --- src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8365c74..0b115d5 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -9,7 +9,7 @@ mp.jwt.token.cookie=jwt quarkus.datasource.db-kind = postgresql quarkus.datasource.username = toto quarkus.datasource.password = toto -quarkus.datasource.jdbc.url = jdbc:postgresql://51.222.107.37:54321/toto +quarkus.datasource.jdbc.url = jdbc:postgresql://db.valczeryba.ovh:54321/toto # drop and create the database at startup (use `update` to only update the schema) #quarkus.hibernate-orm.database.generation = drop-and-create quarkus.hibernate-orm.database.generation = update @@ -25,7 +25,7 @@ quarkus.mailer.password=aohrpmqvxldwyebs quarkus.mailer.mock=false -quarkus.redis.hosts=redis://51.222.107.37:63791 +quarkus.redis.hosts=redis://redis.valczeryba.ovh:63791 quarkus.http.cors=true quarkus.http.origins=http://localhost:8084 From 8cb5c78497f5091e88ee1b9ac763b958cf176df6 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 12 Oct 2022 23:50:46 +0200 Subject: [PATCH 3/8] add variable environment --- src/main/resources/application.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0b115d5..0ce8c45 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -7,9 +7,9 @@ mp.jwt.token.header=Cookie mp.jwt.token.cookie=jwt quarkus.datasource.db-kind = postgresql -quarkus.datasource.username = toto -quarkus.datasource.password = toto -quarkus.datasource.jdbc.url = jdbc:postgresql://db.valczeryba.ovh:54321/toto +quarkus.datasource.username = ${POSTGRES_USER:default} +quarkus.datasource.password = ${POSTGRES_PASSWORD:default} +quarkus.datasource.jdbc.url = jdbc:postgresql://${POSTGRES_URL:localhost}:${POSTGRES_PORT:5432}/${POSTGRES_DB:default} # drop and create the database at startup (use `update` to only update the schema) #quarkus.hibernate-orm.database.generation = drop-and-create quarkus.hibernate-orm.database.generation = update @@ -25,7 +25,7 @@ quarkus.mailer.password=aohrpmqvxldwyebs quarkus.mailer.mock=false -quarkus.redis.hosts=redis://redis.valczeryba.ovh:63791 +quarkus.redis.hosts=redis://${REDIS_URL:localhost}:${REDIS_PORT:6379} quarkus.http.cors=true quarkus.http.origins=http://localhost:8084 From c944982d19ff826092009ac465f7a994e37a0fbc Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 15 Oct 2022 11:34:22 +0200 Subject: [PATCH 4/8] build native image --- pom.xml | 3 + src/main/docker/Dockerfile.multistage | 57 +++++++++++++++++++ .../com/covas/Resources/MailRessource.java | 2 + src/main/resources/application.properties | 2 + ...quarkus-runtime-config-defaults.properties | 0 src/main/resources/resources-config.json | 20 +++++++ 6 files changed, 84 insertions(+) create mode 100644 src/main/docker/Dockerfile.multistage create mode 100644 src/main/resources/quarkus-runtime-config-defaults.properties create mode 100644 src/main/resources/resources-config.json diff --git a/pom.xml b/pom.xml index f40a5b9..e3edc94 100644 --- a/pom.xml +++ b/pom.xml @@ -132,6 +132,7 @@ native + native @@ -161,6 +162,8 @@ + native + -H:ResourceConfigurationFiles=resources-config.json native diff --git a/src/main/docker/Dockerfile.multistage b/src/main/docker/Dockerfile.multistage new file mode 100644 index 0000000..2a6f3ce --- /dev/null +++ b/src/main/docker/Dockerfile.multistage @@ -0,0 +1,57 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# +# Before building the container image run: +# +# ./mvnw package -Pnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.multistage -t quarkus/covas-quarkus . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/covas-quarkus +# +### + +## Stage 1 : build with maven builder image with native capabilities +FROM quay.io/quarkus/ubi-quarkus-native-image:22.2.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 ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline +COPY --chown=quarkus:quarkus src/ /code/src + +ENV POSTGRES_PASSWORD toto +ENV POSTGRES_USER toto +ENV POSTGRES_DB toto +ENV POSTGRES_URL db.valczeryba.ovh +ENV POSTGRES_PORT 54321 +ENV REDIS_URL redis.valczeryba.ovh +ENV REDIS_PORT 63791 +RUN ls -l src/*/*/*/ + +RUN ./mvnw package -Pnative +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5 +WORKDIR /work/ +COPY --from=build /code/target/*-runner /work/application +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work + + +EXPOSE 8080 +USER 1001 + +ENV POSTGRES_PASSWORD toto +ENV POSTGRES_USER toto +ENV POSTGRES_DB toto +ENV POSTGRES_URL db.valczeryba.ovh +ENV POSTGRES_PORT 54321 +ENV REDIS_URL redis.valczeryba.ovh +ENV REDIS_PORT 63791 + +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/java/com/covas/Resources/MailRessource.java b/src/main/java/com/covas/Resources/MailRessource.java index a126c8a..11e52e0 100644 --- a/src/main/java/com/covas/Resources/MailRessource.java +++ b/src/main/java/com/covas/Resources/MailRessource.java @@ -15,12 +15,14 @@ import javax.ws.rs.core.Response; import com.covas.Entity.UsersEntity; import io.quarkus.mailer.MailTemplate; +import io.quarkus.qute.Location; import io.quarkus.redis.client.RedisClient; @Path("mail") public class MailRessource { @Inject + @Location("mailer") private MailTemplate mailer; @Inject diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0ce8c45..872a30c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,7 @@ smallrye.jwt.sign.key.location=privateKey.pem +quarkus.native.additional-build-args =-H:ResourceConfigurationFiles=resources-config.json + mp.jwt.verify.publickey.location=publicKey.pem mp.jwt.verify.issuer=https://example.com/issuer diff --git a/src/main/resources/quarkus-runtime-config-defaults.properties b/src/main/resources/quarkus-runtime-config-defaults.properties new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/resources-config.json b/src/main/resources/resources-config.json new file mode 100644 index 0000000..43b3d8d --- /dev/null +++ b/src/main/resources/resources-config.json @@ -0,0 +1,20 @@ +{ + "resources": [ + { + "pattern": ".*\\.pem$" + }, + { + "pattern": "templates/mailer.txt" + }, + { + "pattern": "application.properties" + }, + { + "pattern": "quarkus-runtime-config-defaults.properties" + }, + + { + "pattern": ".*\\.json$" + } + ] + } \ No newline at end of file From 5e77c865e57d7cd6a46567063677a1f2acd3fea4 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 15 Oct 2022 18:22:13 +0200 Subject: [PATCH 5/8] docker multistage work 100% --- src/main/docker/Dockerfile.centos | 24 +++++++++++++++++++++++ src/main/resources/application.properties | 3 --- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/main/docker/Dockerfile.centos diff --git a/src/main/docker/Dockerfile.centos b/src/main/docker/Dockerfile.centos new file mode 100644 index 0000000..7be530d --- /dev/null +++ b/src/main/docker/Dockerfile.centos @@ -0,0 +1,24 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode +# +# Build the image with: +# +# docker build -f src/main/docker/Dockerfile.multistage -t quarkus/rest-json . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/rest-json +# +### + +FROM quay.io/quarkus/centos-quarkus-maven:21.3.0-java11 AS build +COPY ./pom.xml ./pom.xml +COPY ./src ./src +RUN mvn -Pnative package + +FROM registry.access.redhat.com/ubi8/ubi-minimal +WORKDIR /work/ +COPY --from=build /project/target/*-runner /work/application +RUN chmod 775 /work +EXPOSE 8080 +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 872a30c..6b68cd9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,8 +1,5 @@ smallrye.jwt.sign.key.location=privateKey.pem -quarkus.native.additional-build-args =-H:ResourceConfigurationFiles=resources-config.json - - mp.jwt.verify.publickey.location=publicKey.pem mp.jwt.verify.issuer=https://example.com/issuer mp.jwt.token.header=Cookie From e8b0caadd8785e3a8d949489c6f2f2c136c90f36 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 15 Oct 2022 21:31:27 +0200 Subject: [PATCH 6/8] DockerFile build --- .dockerignore | 2 + Dockerfile | 111 ++++++------------------ build-image.sh | 3 + pom.xml | 3 +- src/main/docker/Dockerfile.centos | 24 ----- src/main/docker/Dockerfile.jvm | 94 -------------------- src/main/docker/Dockerfile.legacy-jar | 90 ------------------- src/main/docker/Dockerfile.multistage | 57 ------------ src/main/docker/Dockerfile.native | 27 ------ src/main/docker/Dockerfile.native-micro | 30 ------- 10 files changed, 34 insertions(+), 407 deletions(-) create mode 100644 build-image.sh delete mode 100644 src/main/docker/Dockerfile.centos delete mode 100644 src/main/docker/Dockerfile.jvm delete mode 100644 src/main/docker/Dockerfile.legacy-jar delete mode 100644 src/main/docker/Dockerfile.multistage delete mode 100644 src/main/docker/Dockerfile.native delete mode 100644 src/main/docker/Dockerfile.native-micro diff --git a/.dockerignore b/.dockerignore index 94810d0..ac54e72 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,6 @@ * +!.pom.xml +!src/ !target/*-runner !target/*-runner.jar !target/lib/* diff --git a/Dockerfile b/Dockerfile index b07af70..072bf12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,94 +1,39 @@ #### -# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode # -# Before building the container image run: +# Build the image with: # -# ./mvnw package -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/covas-quarkus-jvm . +# docker build -f src/main/docker/Dockerfile.multistage -t quarkus/rest-json . # # Then run the container using: # -# docker run -i --rm -p 8080:8080 quarkus/covas-quarkus-jvm -# -# If you want to include the debug port into your docker image -# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 -# -# Then run the container using : -# -# docker run -i --rm -p 8080:8080 quarkus/covas-quarkus-jvm -# -# This image uses the `run-java.sh` script to run the application. -# This scripts computes the command line to execute your Java application, and -# includes memory/GC tuning. -# You can configure the behavior using the following environment properties: -# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") -# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options -# in JAVA_OPTS (example: "-Dsome.property=foo") -# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is -# used to calculate a default maximal heap memory based on a containers restriction. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio -# of the container available memory as set here. The default is `50` which means 50% -# of the available memory is used as an upper boundary. You can skip this mechanism by -# setting this value to `0` in which case no `-Xmx` option is added. -# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This -# is used to calculate a default initial heap memory based on the maximum heap memory. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio -# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` -# is used as the initial heap size. You can skip this mechanism by setting this value -# to `0` in which case no `-Xms` option is added (example: "25") -# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. -# This is used to calculate the maximum value of the initial heap memory. If used in -# a container without any memory constraints for the container then this option has -# no effect. If there is a memory constraint then `-Xms` is limited to the value set -# here. The default is 4096MB which means the calculated value of `-Xms` never will -# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") -# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output -# when things are happening. This option, if set to true, will set -# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). -# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: -# true"). -# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). -# - CONTAINER_CORE_LIMIT: A calculated core limit as described in -# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") -# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). -# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. -# (example: "20") -# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. -# (example: "40") -# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. -# (example: "4") -# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus -# previous GC times. (example: "90") -# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") -# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") -# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should -# contain the necessary JRE command-line options to specify the required GC, which -# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). -# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") -# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") -# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be -# accessed directly. (example: "foo.example.com,bar.example.com") +# docker run -i --rm -p 8080:8080 quarkus/rest-json # ### -FROM registry.access.redhat.com/ubi8/openjdk-11:1.11 -ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' - - -# We make four distinct layers so if there are application changes the library layers can be re-used -COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ -COPY --chown=185 target/quarkus-app/*.jar /deployments/ -COPY --chown=185 target/quarkus-app/app/ /deployments/app/ -COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ +FROM quay.io/quarkus/centos-quarkus-maven:21.3.0-java11 AS build +USER quarkus +COPY --chown=quarkus:quarkus ./pom.xml ./pom.xml +COPY --chown=quarkus:quarkus ./src ./src +ARG POSTGRES_PASSWORD +ARG POSTGRES_USER +ARG POSTGRES_DB +ARG POSTGRES_URL +ARG POSTGRES_PORT +ARG REDIS_URL +ARG REDIS_PORT +RUN mvn -Pnative package +FROM registry.access.redhat.com/ubi8/ubi-minimal +WORKDIR /work/ +COPY --from=build /project/target/*-runner /work/application +RUN chmod 755 /work +ARG POSTGRES_PASSWORD +ARG POSTGRES_USER +ARG POSTGRES_DB +ARG POSTGRES_URL +ARG POSTGRES_PORT +ARG REDIS_URL +ARG REDIS_PORT EXPOSE 8080 -USER 185 -ENV AB_JOLOKIA_OFF="" -ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" -ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" - +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] \ No newline at end of file diff --git a/build-image.sh b/build-image.sh new file mode 100644 index 0000000..a5be74b --- /dev/null +++ b/build-image.sh @@ -0,0 +1,3 @@ +#!/bin/bash +source ../.env +docker build --build-arg POSTGRES_URL=${POSTGRES_URL} --build-arg POSTGRES_PORT=${POSTGRES_PORT} --build-arg POSTGRES_DB=${POSTGRES_DB} --build-arg POSTGRES_USER=${POSTGRES_USER} --build-arg POSTGRES_PASSWORD=${POSTGRES_PASSWORD} --build-arg REDIS_URL=${REDIS_URL} --build-arg REDIS_PORT=${REDIS_PORT} -f src/main/docker/Dockerfile.centos -t quarkus-native . diff --git a/pom.xml b/pom.xml index e3edc94..5232c38 100644 --- a/pom.xml +++ b/pom.xml @@ -150,6 +150,7 @@ verify + ${project.build.directory}/${project.build.finalName}-runner org.jboss.logmanager.LogManager @@ -163,8 +164,6 @@ native - -H:ResourceConfigurationFiles=resources-config.json - native diff --git a/src/main/docker/Dockerfile.centos b/src/main/docker/Dockerfile.centos deleted file mode 100644 index 7be530d..0000000 --- a/src/main/docker/Dockerfile.centos +++ /dev/null @@ -1,24 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode -# -# Build the image with: -# -# docker build -f src/main/docker/Dockerfile.multistage -t quarkus/rest-json . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/rest-json -# -### - -FROM quay.io/quarkus/centos-quarkus-maven:21.3.0-java11 AS build -COPY ./pom.xml ./pom.xml -COPY ./src ./src -RUN mvn -Pnative package - -FROM registry.access.redhat.com/ubi8/ubi-minimal -WORKDIR /work/ -COPY --from=build /project/target/*-runner /work/application -RUN chmod 775 /work -EXPOSE 8080 -CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] \ No newline at end of file diff --git a/src/main/docker/Dockerfile.jvm b/src/main/docker/Dockerfile.jvm deleted file mode 100644 index b07af70..0000000 --- a/src/main/docker/Dockerfile.jvm +++ /dev/null @@ -1,94 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode -# -# Before building the container image run: -# -# ./mvnw package -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/covas-quarkus-jvm . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/covas-quarkus-jvm -# -# If you want to include the debug port into your docker image -# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 -# -# Then run the container using : -# -# docker run -i --rm -p 8080:8080 quarkus/covas-quarkus-jvm -# -# This image uses the `run-java.sh` script to run the application. -# This scripts computes the command line to execute your Java application, and -# includes memory/GC tuning. -# You can configure the behavior using the following environment properties: -# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") -# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options -# in JAVA_OPTS (example: "-Dsome.property=foo") -# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is -# used to calculate a default maximal heap memory based on a containers restriction. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio -# of the container available memory as set here. The default is `50` which means 50% -# of the available memory is used as an upper boundary. You can skip this mechanism by -# setting this value to `0` in which case no `-Xmx` option is added. -# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This -# is used to calculate a default initial heap memory based on the maximum heap memory. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio -# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` -# is used as the initial heap size. You can skip this mechanism by setting this value -# to `0` in which case no `-Xms` option is added (example: "25") -# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. -# This is used to calculate the maximum value of the initial heap memory. If used in -# a container without any memory constraints for the container then this option has -# no effect. If there is a memory constraint then `-Xms` is limited to the value set -# here. The default is 4096MB which means the calculated value of `-Xms` never will -# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") -# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output -# when things are happening. This option, if set to true, will set -# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). -# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: -# true"). -# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). -# - CONTAINER_CORE_LIMIT: A calculated core limit as described in -# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") -# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). -# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. -# (example: "20") -# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. -# (example: "40") -# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. -# (example: "4") -# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus -# previous GC times. (example: "90") -# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") -# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") -# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should -# contain the necessary JRE command-line options to specify the required GC, which -# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). -# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") -# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") -# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be -# accessed directly. (example: "foo.example.com,bar.example.com") -# -### -FROM registry.access.redhat.com/ubi8/openjdk-11:1.11 - -ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' - - -# We make four distinct layers so if there are application changes the library layers can be re-used -COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ -COPY --chown=185 target/quarkus-app/*.jar /deployments/ -COPY --chown=185 target/quarkus-app/app/ /deployments/app/ -COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ - -EXPOSE 8080 -USER 185 -ENV AB_JOLOKIA_OFF="" -ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" -ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" - diff --git a/src/main/docker/Dockerfile.legacy-jar b/src/main/docker/Dockerfile.legacy-jar deleted file mode 100644 index e6a19e9..0000000 --- a/src/main/docker/Dockerfile.legacy-jar +++ /dev/null @@ -1,90 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode -# -# Before building the container image run: -# -# ./mvnw package -Dquarkus.package.type=legacy-jar -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/covas-quarkus-legacy-jar . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/covas-quarkus-legacy-jar -# -# If you want to include the debug port into your docker image -# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 -# -# Then run the container using : -# -# docker run -i --rm -p 8080:8080 quarkus/covas-quarkus-legacy-jar -# -# This image uses the `run-java.sh` script to run the application. -# This scripts computes the command line to execute your Java application, and -# includes memory/GC tuning. -# You can configure the behavior using the following environment properties: -# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") -# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options -# in JAVA_OPTS (example: "-Dsome.property=foo") -# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is -# used to calculate a default maximal heap memory based on a containers restriction. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio -# of the container available memory as set here. The default is `50` which means 50% -# of the available memory is used as an upper boundary. You can skip this mechanism by -# setting this value to `0` in which case no `-Xmx` option is added. -# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This -# is used to calculate a default initial heap memory based on the maximum heap memory. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio -# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` -# is used as the initial heap size. You can skip this mechanism by setting this value -# to `0` in which case no `-Xms` option is added (example: "25") -# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. -# This is used to calculate the maximum value of the initial heap memory. If used in -# a container without any memory constraints for the container then this option has -# no effect. If there is a memory constraint then `-Xms` is limited to the value set -# here. The default is 4096MB which means the calculated value of `-Xms` never will -# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") -# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output -# when things are happening. This option, if set to true, will set -# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). -# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: -# true"). -# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). -# - CONTAINER_CORE_LIMIT: A calculated core limit as described in -# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") -# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). -# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. -# (example: "20") -# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. -# (example: "40") -# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. -# (example: "4") -# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus -# previous GC times. (example: "90") -# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") -# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") -# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should -# contain the necessary JRE command-line options to specify the required GC, which -# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). -# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") -# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") -# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be -# accessed directly. (example: "foo.example.com,bar.example.com") -# -### -FROM registry.access.redhat.com/ubi8/openjdk-11:1.11 - -ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' - - -COPY target/lib/* /deployments/lib/ -COPY target/*-runner.jar /deployments/quarkus-run.jar - -EXPOSE 8080 -USER 185 -ENV AB_JOLOKIA_OFF="" -ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" -ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" diff --git a/src/main/docker/Dockerfile.multistage b/src/main/docker/Dockerfile.multistage deleted file mode 100644 index 2a6f3ce..0000000 --- a/src/main/docker/Dockerfile.multistage +++ /dev/null @@ -1,57 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. -# -# Before building the container image run: -# -# ./mvnw package -Pnative -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.multistage -t quarkus/covas-quarkus . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/covas-quarkus -# -### - -## Stage 1 : build with maven builder image with native capabilities -FROM quay.io/quarkus/ubi-quarkus-native-image:22.2.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 ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline -COPY --chown=quarkus:quarkus src/ /code/src - -ENV POSTGRES_PASSWORD toto -ENV POSTGRES_USER toto -ENV POSTGRES_DB toto -ENV POSTGRES_URL db.valczeryba.ovh -ENV POSTGRES_PORT 54321 -ENV REDIS_URL redis.valczeryba.ovh -ENV REDIS_PORT 63791 -RUN ls -l src/*/*/*/ - -RUN ./mvnw package -Pnative -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5 -WORKDIR /work/ -COPY --from=build /code/target/*-runner /work/application -RUN chown 1001 /work \ - && chmod "g+rwX" /work \ - && chown 1001:root /work - - -EXPOSE 8080 -USER 1001 - -ENV POSTGRES_PASSWORD toto -ENV POSTGRES_USER toto -ENV POSTGRES_DB toto -ENV POSTGRES_URL db.valczeryba.ovh -ENV POSTGRES_PORT 54321 -ENV REDIS_URL redis.valczeryba.ovh -ENV REDIS_PORT 63791 - -CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/docker/Dockerfile.native b/src/main/docker/Dockerfile.native deleted file mode 100644 index 22e933e..0000000 --- a/src/main/docker/Dockerfile.native +++ /dev/null @@ -1,27 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. -# -# Before building the container image run: -# -# ./mvnw package -Pnative -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.native -t quarkus/covas-quarkus . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/covas-quarkus -# -### -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5 -WORKDIR /work/ -RUN chown 1001 /work \ - && chmod "g+rwX" /work \ - && chown 1001:root /work -COPY --chown=1001:root target/*-runner /work/application - -EXPOSE 8080 -USER 1001 - -CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/docker/Dockerfile.native-micro b/src/main/docker/Dockerfile.native-micro deleted file mode 100644 index cf87322..0000000 --- a/src/main/docker/Dockerfile.native-micro +++ /dev/null @@ -1,30 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. -# It uses a micro base image, tuned for Quarkus native executables. -# It reduces the size of the resulting container image. -# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image. -# -# Before building the container image run: -# -# ./mvnw package -Pnative -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/covas-quarkus . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/covas-quarkus -# -### -FROM quay.io/quarkus/quarkus-micro-image:1.0 -WORKDIR /work/ -RUN chown 1001 /work \ - && chmod "g+rwX" /work \ - && chown 1001:root /work -COPY --chown=1001:root target/*-runner /work/application - -EXPOSE 8080 -USER 1001 - -CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] From b3313596d1d133a815ce8c8f092c008641107373 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 15 Oct 2022 21:42:34 +0200 Subject: [PATCH 7/8] change dockerfile and update gitignore --- .dockerignore | 2 +- build-image.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index ac54e72..4ecfe09 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,5 @@ * -!.pom.xml +!pom.xml !src/ !target/*-runner !target/*-runner.jar diff --git a/build-image.sh b/build-image.sh index a5be74b..c05fc0d 100644 --- a/build-image.sh +++ b/build-image.sh @@ -1,3 +1,3 @@ #!/bin/bash source ../.env -docker build --build-arg POSTGRES_URL=${POSTGRES_URL} --build-arg POSTGRES_PORT=${POSTGRES_PORT} --build-arg POSTGRES_DB=${POSTGRES_DB} --build-arg POSTGRES_USER=${POSTGRES_USER} --build-arg POSTGRES_PASSWORD=${POSTGRES_PASSWORD} --build-arg REDIS_URL=${REDIS_URL} --build-arg REDIS_PORT=${REDIS_PORT} -f src/main/docker/Dockerfile.centos -t quarkus-native . +docker build --build-arg POSTGRES_URL=${POSTGRES_URL} --build-arg POSTGRES_PORT=${POSTGRES_PORT} --build-arg POSTGRES_DB=${POSTGRES_DB} --build-arg POSTGRES_USER=${POSTGRES_USER} --build-arg POSTGRES_PASSWORD=${POSTGRES_PASSWORD} --build-arg REDIS_URL=${REDIS_URL} --build-arg REDIS_PORT=${REDIS_PORT} -t quarkus-native . From 4d3d21474cff330ec39f68b9cbe851a41f3a334c Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 15 Oct 2022 21:45:39 +0200 Subject: [PATCH 8/8] remove file useless --- ...quarkus-runtime-config-defaults.properties | 0 src/main/resources/resources-config.json | 20 ------------------- 2 files changed, 20 deletions(-) delete mode 100644 src/main/resources/quarkus-runtime-config-defaults.properties delete mode 100644 src/main/resources/resources-config.json diff --git a/src/main/resources/quarkus-runtime-config-defaults.properties b/src/main/resources/quarkus-runtime-config-defaults.properties deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/resources/resources-config.json b/src/main/resources/resources-config.json deleted file mode 100644 index 43b3d8d..0000000 --- a/src/main/resources/resources-config.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "resources": [ - { - "pattern": ".*\\.pem$" - }, - { - "pattern": "templates/mailer.txt" - }, - { - "pattern": "application.properties" - }, - { - "pattern": "quarkus-runtime-config-defaults.properties" - }, - - { - "pattern": ".*\\.json$" - } - ] - } \ No newline at end of file