From 7a31c73f4a61c01eeceace93f777ee4a219ea02e Mon Sep 17 00:00:00 2001 From: harayuanwang Date: Tue, 23 Nov 2021 15:39:29 -0500 Subject: [PATCH 1/4] add native image --- .../autonomousdb-wallet-secret-sample/pom.xml | 3 ++- .../src/main/docker/Dockerfile.nativeimage | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 java/autonomousdb-wallet-secret-sample/src/main/docker/Dockerfile.nativeimage diff --git a/java/autonomousdb-wallet-secret-sample/pom.xml b/java/autonomousdb-wallet-secret-sample/pom.xml index c4ae17f2..b36789a8 100644 --- a/java/autonomousdb-wallet-secret-sample/pom.xml +++ b/java/autonomousdb-wallet-secret-sample/pom.xml @@ -110,6 +110,7 @@ true Dockerfile + Dockerfile.nativeimage @@ -159,4 +160,4 @@ 21.3.0.0 - \ No newline at end of file + diff --git a/java/autonomousdb-wallet-secret-sample/src/main/docker/Dockerfile.nativeimage b/java/autonomousdb-wallet-secret-sample/src/main/docker/Dockerfile.nativeimage new file mode 100644 index 00000000..f96706f9 --- /dev/null +++ b/java/autonomousdb-wallet-secret-sample/src/main/docker/Dockerfile.nativeimage @@ -0,0 +1,22 @@ +FROM ghcr.io/graalvm/graalvm-ce:21.3.0 +RUN gu install native-image + +RUN mkdir /app +COPY libs /app/libs +COPY ${project.artifactId}.jar /app + +RUN native-image -jar /app/${project.artifactId}.jar -H:Name=/app/${project.artifactId} + +FROM oraclelinux:8-slim +RUN mkdir /app +COPY --from=0 "/app/${project.artifactId}" /app/${project.artifactId} +WORKDIR /app + +# The driver will look for the wallet in folder /app/wallet +# This value must match the one in the mountPath of the container +# Reference in src/main/k8s/app.yaml + +CMD ["/app/${project.artifactId}", \ + "-Doracle.net.tns_admin=/app/wallet", \ + "-Doracle.net.wallet_location=/app/wallet", \ + "-Doracle.jdbc.fanEnabled=false"] From a4a7a258f76d1c5c46fbe3871c6fa0f3c4300d44 Mon Sep 17 00:00:00 2001 From: harayuanwang Date: Tue, 23 Nov 2021 15:45:54 -0500 Subject: [PATCH 2/4] update README.md --- java/autonomousdb-wallet-secret-sample/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/java/autonomousdb-wallet-secret-sample/README.md b/java/autonomousdb-wallet-secret-sample/README.md index e75c467e..82f59bb6 100644 --- a/java/autonomousdb-wallet-secret-sample/README.md +++ b/java/autonomousdb-wallet-secret-sample/README.md @@ -17,6 +17,7 @@ If you want to configure a previously downloaded wallet you can just create the ```sh kubectl create secret generic instance-wallet --from-file= ``` + The Java microservice retrieves username, password and url also from a secret. To create it you can use the following script as an example: ```sh @@ -25,6 +26,7 @@ kubectl create secret generic user-jdbc \ --from-literal=password='' \ --from-literal=url='jdbc:oracle:thin:@' ``` + ## Install, build and deploy It is as simple as to build the maven project, create the docker image and deploy the Pod: @@ -35,6 +37,14 @@ docker build -t adb-health-check target kubectl apply -f target/app.yaml ``` +If you want to run the application as a [GraalVM Native Image](https://www.graalvm.org/reference-manual/native-image/), simply specify the different Dockerfile `target/Dockerfile.nativeimage` and repeat the rest of the steps. + +```sh +mvn clean install +docker build -f target/Dockerfile.nativeimage -t adb-health-check target +kubectl apply -f target/app.yaml +``` + ## Usage After successsful installation you can validate first connectivity through the Pod's log: From 27f2076bd25c3d6eda96856ae1a2c1f3389191f1 Mon Sep 17 00:00:00 2001 From: Ting-Lan Wang <61528376+harayuanwang@users.noreply.github.com> Date: Wed, 24 Nov 2021 14:59:48 -0800 Subject: [PATCH 3/4] Update Dockerfile.nativeimage --- .../src/main/docker/Dockerfile.nativeimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/autonomousdb-wallet-secret-sample/src/main/docker/Dockerfile.nativeimage b/java/autonomousdb-wallet-secret-sample/src/main/docker/Dockerfile.nativeimage index f96706f9..c17150c4 100644 --- a/java/autonomousdb-wallet-secret-sample/src/main/docker/Dockerfile.nativeimage +++ b/java/autonomousdb-wallet-secret-sample/src/main/docker/Dockerfile.nativeimage @@ -9,7 +9,7 @@ RUN native-image -jar /app/${project.artifactId}.jar -H:Name=/app/${project.arti FROM oraclelinux:8-slim RUN mkdir /app -COPY --from=0 "/app/${project.artifactId}" /app/${project.artifactId} +COPY --from=0 "/app/${project.artifactId}" "/app/${project.artifactId}" WORKDIR /app # The driver will look for the wallet in folder /app/wallet From 8f0f64f7d085b39e9914101b1c1d66eb591c7646 Mon Sep 17 00:00:00 2001 From: Ting-Lan Wang <61528376+harayuanwang@users.noreply.github.com> Date: Tue, 30 Nov 2021 08:01:15 -0800 Subject: [PATCH 4/4] Update README.md --- java/autonomousdb-wallet-secret-sample/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/autonomousdb-wallet-secret-sample/README.md b/java/autonomousdb-wallet-secret-sample/README.md index 82f59bb6..eedaf90b 100644 --- a/java/autonomousdb-wallet-secret-sample/README.md +++ b/java/autonomousdb-wallet-secret-sample/README.md @@ -37,7 +37,9 @@ docker build -t adb-health-check target kubectl apply -f target/app.yaml ``` -If you want to run the application as a [GraalVM Native Image](https://www.graalvm.org/reference-manual/native-image/), simply specify the different Dockerfile `target/Dockerfile.nativeimage` and repeat the rest of the steps. +If you want to run the application as a [GraalVM Native Image](https://www.graalvm.org/reference-manual/native-image/), it is very likely that the build process will be frozen since GraalVM Native Image compilation process is really RAM-intensive. To prevent from the issue, we recommend allotting the Docker engine around **9 to 12 GB of RAM**. + +After that, simply specify the different Dockerfile `target/Dockerfile.nativeimage` and repeat the rest of the steps. ```sh mvn clean install