diff --git a/theodolite/README.md b/theodolite/README.md index 96f56c20db1d0796ba692cc497b93532517526ff..f662329f7eda3a39632581b7125a2f2f2feced8a 100644 --- a/theodolite/README.md +++ b/theodolite/README.md @@ -1,12 +1,12 @@ -# Theodolite project +# Theodolite This project uses Quarkus, the Supersonic Subatomic Java Framework. -If you want to learn more about Quarkus, please visit its website: <https://quarkus.io/> . +If you want to learn more about Quarkus, please visit its website: https://quarkus.io/. ## Running the application in dev mode -You can run your application in dev mode using: +You can run your application in dev mode that enables live coding using: ```sh ./gradlew quarkusDev @@ -23,8 +23,10 @@ The application can be packaged using: ./gradlew build ``` -It produces the `theodolite-0.7.0-SNAPSHOT-runner.jar` file in the `/build` directory. Be aware that it’s not -an _über-jar_ as the dependencies are copied into the `build/lib` directory. +It produces the `quarkus-run.jar` file in the `build/quarkus-app/` directory. +Be aware that it’s not an _über-jar_ as the dependencies are copied into the `build/quarkus-app/lib/` directory. + +The application is now runnable using `java -jar build/quarkus-app/quarkus-run.jar`. If you want to build an _über-jar_, execute the following command: @@ -32,12 +34,10 @@ If you want to build an _über-jar_, execute the following command: ./gradlew build -Dquarkus.package.type=uber-jar ``` -The application is now runnable using `java -jar build/theodolite-0.7.0-SNAPSHOT-runner.jar`. +The application, packaged as an _über-jar_, is now runnable using `java -jar build/*-runner.jar`. ## Creating a native executable -It is recommended to use the native GraalVM images to create executable jars from Theodolite. For more information please visit the [Native Image guide](https://www.graalvm.org/reference-manual/native-image/). - You can create a native executable using: ```sh @@ -55,15 +55,21 @@ You can then execute your native executable with: If you want to learn more about building native executables, please consult https://quarkus.io/guides/gradle-tooling. -## Build docker images +## Building container images -For the jvm version use: +For the JVM version use: ```sh ./gradlew build docker build -f src/main/docker/Dockerfile.jvm -t theodolite-jvm . ``` +Alternatively, you can also use Kaniko to build the image: + +```sh +docker run -it --rm --name kaniko -v "`pwd`":/theodolite --entrypoint "" gcr.io/kaniko-project/executor:debug /kaniko/executor --context /theodolite --dockerfile src/main/docker/Dockerfile.jvm --no-push +``` + For the native image version use: ```sh @@ -71,7 +77,7 @@ For the native image version use: docker build -f src/main/docker/Dockerfile.native -t theodolite-native . ``` -## Execute docker images +## Run a container Remember to set the environment variables first. diff --git a/theodolite/build.gradle b/theodolite/build.gradle index 0ec113cbba893bc1f2f44a60c270f7cb67688803..a066e94f09b71720f9392947640b077b153ccb9c 100644 --- a/theodolite/build.gradle +++ b/theodolite/build.gradle @@ -1,14 +1,14 @@ plugins { - id 'org.jetbrains.kotlin.jvm' version "1.5.31" - id "org.jetbrains.kotlin.plugin.allopen" version "1.5.31" + id 'org.jetbrains.kotlin.jvm' version "1.6.10" + id "org.jetbrains.kotlin.plugin.allopen" version "1.6.10" id 'io.quarkus' id "io.gitlab.arturbosch.detekt" version "1.15.0" id "org.jlleitschuh.gradle.ktlint" version "10.0.0" } repositories { - mavenLocal() mavenCentral() + mavenLocal() jcenter() } diff --git a/theodolite/build_jvm.sh b/theodolite/build_jvm.sh deleted file mode 100755 index f4dd32fc5228576f09e95f0e8ac06fa08ea6acc7..0000000000000000000000000000000000000000 --- a/theodolite/build_jvm.sh +++ /dev/null @@ -1,6 +0,0 @@ - -./gradlew build -x test - -docker build -f src/main/docker/Dockerfile.jvm -t quarkus/theodolite-jvm . - -docker run -i --rm -p 8080:8080 quarkus/theodolite-jvm diff --git a/theodolite/build_native.sh b/theodolite/build_native.sh deleted file mode 100755 index c2d7d81f35a24af951005bb30c52a8ab494ddb64..0000000000000000000000000000000000000000 --- a/theodolite/build_native.sh +++ /dev/null @@ -1,6 +0,0 @@ - -./gradlew build -Dquarkus.package.type=native -x test - -docker build -f src/main/docker/Dockerfile.native -t quarkus/theodolite . - -docker run -i --rm -p 8080:8080 quarkus/theodolite diff --git a/theodolite/gradle.properties b/theodolite/gradle.properties index 76ed8f2136f14263460bc391d420c78de200d659..fd5768bc24a65dbd43b3ea770c854ae7c0da0a91 100644 --- a/theodolite/gradle.properties +++ b/theodolite/gradle.properties @@ -1,8 +1,8 @@ #Gradle properties -quarkusPluginVersion=2.5.2.Final -quarkusPlatformArtifactId=quarkus-bom quarkusPluginId=io.quarkus +quarkusPluginVersion=2.6.3.Final quarkusPlatformGroupId=io.quarkus.platform -quarkusPlatformVersion=2.5.2.Final +quarkusPlatformArtifactId=quarkus-bom +quarkusPlatformVersion=2.6.3.Final #org.gradle.logging.level=INFO \ No newline at end of file diff --git a/theodolite/src/main/docker/Dockerfile.jvm b/theodolite/src/main/docker/Dockerfile.jvm index 03035752038fee2e5ce4c477c61adc84991f3729..e33d7c379a4336610c16d59b9d3315a1e8abad2b 100644 --- a/theodolite/src/main/docker/Dockerfile.jvm +++ b/theodolite/src/main/docker/Dockerfile.jvm @@ -18,38 +18,24 @@ # # Then run the container using : # -# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/theodolite-jvm +# docker run -i --rm -p 8080:8080 quarkus/theodolite-jvm # ### -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 +FROM registry.access.redhat.com/ubi8/openjdk-11-runtime:1.10 -ARG JAVA_PACKAGE=java-11-openjdk-headless -ARG RUN_JAVA_VERSION=1.3.8 ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' -# Install java and the run-java script -# Also set up permissions for user `1001` -RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ - && microdnf update \ - && microdnf clean all \ - && mkdir /deployments \ - && chown 1001 /deployments \ - && chmod "g+rwX" /deployments \ - && chown 1001:root /deployments \ - && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ - && chown 1001 /deployments/run-java.sh \ - && chmod 540 /deployments/run-java.sh \ - && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" + # We make four distinct layers so if there are application changes the library layers can be re-used -COPY --chown=1001 build/quarkus-app/lib/ /deployments/lib/ -COPY --chown=1001 build/quarkus-app/*.jar /deployments/ -COPY --chown=1001 build/quarkus-app/app/ /deployments/app/ -COPY --chown=1001 build/quarkus-app/quarkus/ /deployments/quarkus/ +COPY --chown=185 build/quarkus-app/lib/ /deployments/lib/ +COPY --chown=185 build/quarkus-app/*.jar /deployments/ +COPY --chown=185 build/quarkus-app/app/ /deployments/app/ +COPY --chown=185 build/quarkus-app/quarkus/ /deployments/quarkus/ EXPOSE 8080 -USER 1001 +USER 185 -ENTRYPOINT [ "/deployments/run-java.sh" ] +ENTRYPOINT [ "java", "-jar", "/deployments/quarkus-run.jar" ] diff --git a/theodolite/src/main/docker/Dockerfile.legacy-jar b/theodolite/src/main/docker/Dockerfile.legacy-jar index f9dffd188570c14087bafaec838b58b61a4e5912..aa5908c4ed42f005fa67c17fd2c3b3e00978228a 100644 --- a/theodolite/src/main/docker/Dockerfile.legacy-jar +++ b/theodolite/src/main/docker/Dockerfile.legacy-jar @@ -18,34 +18,20 @@ # # Then run the container using : # -# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/theodolite-legacy-jar +# docker run -i --rm -p 8080:8080 quarkus/theodolite-legacy-jar # ### -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 +FROM registry.access.redhat.com/ubi8/openjdk-11-runtime:1.10 -ARG JAVA_PACKAGE=java-11-openjdk-headless -ARG RUN_JAVA_VERSION=1.3.8 ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' -# Install java and the run-java script -# Also set up permissions for user `1001` -RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ - && microdnf update \ - && microdnf clean all \ - && mkdir /deployments \ - && chown 1001 /deployments \ - && chmod "g+rwX" /deployments \ - && chown 1001:root /deployments \ - && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ - && chown 1001 /deployments/run-java.sh \ - && chmod 540 /deployments/run-java.sh \ - && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" + COPY build/lib/* /deployments/lib/ -COPY build/*-runner.jar /deployments/app.jar +COPY build/*-runner.jar /deployments/quarkus-run.jar EXPOSE 8080 -USER 1001 +USER 185 -ENTRYPOINT [ "/deployments/run-java.sh" ] +ENTRYPOINT [ "java", "-jar", "/deployments/quarkus-run.jar" ] diff --git a/theodolite/src/main/docker/Dockerfile.native b/theodolite/src/main/docker/Dockerfile.native index 04a1dd6f2b6cc99511bf705eed5d98be1da25b05..34ccd6622bf2fba6f9707989fffd9bb6390a4a8b 100644 --- a/theodolite/src/main/docker/Dockerfile.native +++ b/theodolite/src/main/docker/Dockerfile.native @@ -14,12 +14,12 @@ # docker run -i --rm -p 8080:8080 quarkus/theodolite # ### -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 -WORKDIR /deployments/ -RUN chown 1001 /deployments \ - && chmod "g+rwX" /deployments \ - && chown 1001:root /deployments -COPY --chown=1001:root build/*-runner /deployments/application +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 build/*-runner /work/application EXPOSE 8080 USER 1001 diff --git a/theodolite/src/main/docker/Dockerfile.native-distroless b/theodolite/src/main/docker/Dockerfile.native-distroless index 1ed64110dd931bf3fea9100e3318318ad40b6966..951dfb64bee56e277d057c8f9e97796e88f30ac2 100644 --- a/theodolite/src/main/docker/Dockerfile.native-distroless +++ b/theodolite/src/main/docker/Dockerfile.native-distroless @@ -15,8 +15,7 @@ # ### FROM quay.io/quarkus/quarkus-distroless-image:1.0 -WORKDIR /deployments/ -COPY build/*-runner /deployments/application +COPY build/*-runner /application EXPOSE 8080 USER nonroot