From 0de257fd44f42c5706448ccc589761604229b6a5 Mon Sep 17 00:00:00 2001 From: Victor Romero Date: Mon, 25 Oct 2021 17:35:47 -0500 Subject: [PATCH] Use of Azul Zulu JDK 11 LTS (FINERACT-1416) --- .travis.yml | 30 ++++++++++++++++++++++++------ Dockerfile | 14 ++++++++++---- entrypoint.sh | 12 ++++++++++++ 3 files changed, 46 insertions(+), 10 deletions(-) create mode 100755 entrypoint.sh diff --git a/.travis.yml b/.travis.yml index 63b54d6af..67afdd32b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,17 +41,24 @@ addons: # See https://issues.apache.org/jira/browse/FINERACT-937 for background re. what below is all about.. # We basically remove the outdated OpenJDK 11.0.2 which Travis image grabbed from java.net in # https://github.com/travis-ci/travis-cookbooks/blob/master/cookbooks/travis_jdk/files/install-jdk.sh#L200 -# (which has 11.0.2 hard-coded!), and instead replace it with the latest openjdk-11-jdk-headless Ubuntu package. +# (which has 11.0.2 hard-coded!), and instead replace it with the latest Azul Zulu Debian package. # NB /usr/local/lib/jvm/openjdk11/bin is also on the PATH, but there's no need to change it (because we rm -rf anyway) +# Installing Azul Zulu as per official instructions https://docs.azul.com/core/zulu-openjdk/install/debian before_install: - echo $JAVA_HOME - which java - sudo rm -rf /usr/local/lib/jvm/ - - sudo apt-get install -y openjdk-11-jdk-headless - - export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/ - - which java - - java -version - - $JAVA_HOME/bin/java -version + +install: + - unset _JAVA_OPTIONS + - sudo apt-get -q update + - sudo apt-get -yq install gnupg curl + - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9 + - curl -O https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb + - sudo apt-get -yq install ./zulu-repo_1.0.0-3_all.deb + - sudo apt-get -q update + - sudo apt-get -yq install zulu11-jdk + - export JAVA_HOME=/usr/lib/jvm/zulu11 - echo "USE mysql;\nALTER USER 'root'@'localhost' IDENTIFIED BY 'mysql';\n" | mysql -u root - mysql -u root -pmysql -e 'CREATE DATABASE IF NOT EXISTS `fineract_tenants`;' - mysql -u root -pmysql -e 'CREATE DATABASE IF NOT EXISTS `fineract_default`;' @@ -68,6 +75,17 @@ cache: - $HOME/.gradle/wrapper/ - $HOME/.m2 +# Check Java environment variables +before_script: + - echo $JDK_JAVA_OPTIONS + - echo $JAVA_OPTIONS + - echo $JAVA_HOME + - which java + - java -version + - which javac + - javac -version + - $JAVA_HOME/bin/java -version + # NOTE: We used to run with --info, which is quite a bit more verbose, but is VERY useful to understand failures on Travis, # where you do not have access to any files like build/reports/tests/index.html, only the Console. # @see http://mrhaki.blogspot.ch/2013/05/gradle-goodness-show-more-information.html diff --git a/Dockerfile b/Dockerfile index 361d02972..4595ddda1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. # -FROM openjdk:11 AS builder +FROM azul/zulu-openjdk-debian:11 AS builder RUN apt-get update -qq && apt-get install -y wget @@ -34,11 +34,17 @@ RUN wget -q https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.23/mys # ========================================= -FROM gcr.io/distroless/java:11 as fineract +FROM azul/zulu-openjdk-alpine:11 AS fineract COPY --from=builder /fineract/fineract-provider/build/libs /app COPY --from=builder /fineract/libs /app/libs -WORKDIR /app +WORKDIR / -ENTRYPOINT ["java", "-Dloader.path=/app/libs/", "-jar", "/app/fineract-provider.jar"] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod 775 /entrypoint.sh + +EXPOSE 8443 + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 000000000..6084c034c --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +while ! nc -zvw3 fineractmysql 3306 ; do + >&2 echo "DB Server is unavailable - sleeping" + sleep 5 +done +>&2 echo "DB Server is up - executing command" + +java -Dloader.path=/app/libs/ -jar /app/fineract-provider.jar +