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