Use integration-java11 Dockerfile

Use onap/integration-java11:7.1.0 as a source for the images requiring JDK 11 in SDC

Issue-ID: SDC-3298
Change-Id: Ifee3d2942dcb9c078f2ebb686bdabc0ecca857b3
Signed-off-by: xuegao <xue.gao@intl.att.com>
diff --git a/catalog-fe/sdc-frontend/Dockerfile b/catalog-fe/sdc-frontend/Dockerfile
index 3a2359c..65950cb 100644
--- a/catalog-fe/sdc-frontend/Dockerfile
+++ b/catalog-fe/sdc-frontend/Dockerfile
@@ -1,17 +1,13 @@
-FROM jetty:9.4.31-jre11-slim
+FROM onap/integration-java11:8.0.0
 
 USER root
+ARG JETTY_FOLDER=/app/jetty
 
 # Install Chef
 RUN set -ex && \
-    apt-get update -y && \
-    apt-get install -y \
-        jq \
-        curl \
-        curl \
-        vim \
-        make \
-        gcc \
+    apk update && \
+    apk add --no-cache \
+        build-base \
         ruby \
         ruby-dev \
         libffi-dev \
@@ -23,39 +19,30 @@
         etc webrick \
         --no-document && \
     gem cleanup && \
-    apt-get update -y && \
-    apt-get install -y binutils jq && \
-    apt-get clean
+    apk update
 
-# Replace Jetty user ID
-ENV USER_JETTY="jetty"
-ENV GROUP_JETTY="jetty"
-ENV UID_JETTY="352070"
-ENV GID_JETTY="35953"
+ENV JETTY_HOME=$JETTY_FOLDER
+ENV JETTY_BASE=$JETTY_FOLDER
+ENV JETTY_USER=onap
+ENV JETTY_GROUP=onap
 
-# Remove user:
-RUN deluser ${USER_JETTY}
-#RUN delgroup ${GROUP_JETTY}
-RUN echo "${USER_JETTY}:x:${UID_JETTY}:${GID_JETTY}::/home/${USER_JETTY}:Linux User,,,:/home/jetty:/bin/false" >> /etc/passwd
-RUN echo "${GROUP_JETTY}:x:${GID_JETTY}:${USER_JETTY}" >> /etc/group
-RUN echo "${USER_JETTY}:!:17501:0:99999:7:::" >> /etc/shadow
-RUN mkdir /home/${USER_JETTY} && chown ${USER_JETTY}:${GROUP_JETTY} /home/${USER_JETTY}
-RUN chown -R jetty:jetty ${JETTY_BASE}/webapps /var/lib/jetty
+RUN mkdir $JETTY_FOLDER && chown onap:onap $JETTY_FOLDER
 
-USER jetty
+USER onap
 
-RUN mkdir -p ${JETTY_BASE}/config/catalog-fe
+#Download jetty
+RUN wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.4.31.v20200723/jetty-distribution-9.4.31.v20200723.tar.gz -O $JETTY_FOLDER/jetty.tar.gz && \
+        tar xvz -C $JETTY_FOLDER -f $JETTY_FOLDER/jetty.tar.gz --strip 1 && \
+        rm -rf $JETTY_FOLDER/jetty.tar.gz
+RUN sed -i 's/"jetty"/"onap"/g' $JETTY_FOLDER/etc/jetty-setuid.xml
 
-COPY --chown=jetty:jetty chef-solo ${JETTY_BASE}/chef-solo/
+RUN mkdir -p $JETTY_FOLDER/config/catalog-fe
+COPY --chown=onap:onap chef-solo $JETTY_FOLDER/chef-solo/
+COPY --chown=onap:onap  chef-repo/cookbooks $JETTY_FOLDER/chef-solo/cookbooks/
+ADD --chown=onap:onap onboarding*.war         $JETTY_FOLDER/webapps/
+ADD --chown=onap:onap  catalog-fe-*.war        $JETTY_FOLDER/webapps/
+COPY --chown=onap:onap  startup.sh $JETTY_FOLDER
 
-COPY --chown=jetty:jetty chef-repo/cookbooks ${JETTY_BASE}/chef-solo/cookbooks/
+RUN chmod 770 $JETTY_FOLDER/startup.sh
 
-ADD --chown=jetty:jetty onboarding*.war         ${JETTY_BASE}/webapps/
-
-ADD --chown=jetty:jetty catalog-fe-*.war        ${JETTY_BASE}/webapps/
-
-COPY --chown=jetty:jetty startup.sh ${JETTY_BASE}
-
-RUN chmod 770 ${JETTY_BASE}/startup.sh
-
-ENTRYPOINT [ "sh", "-c", "${JETTY_BASE}/startup.sh"]
\ No newline at end of file
+ENTRYPOINT [ "sh", "-c", "${JETTY_HOME}/startup.sh"]
\ No newline at end of file
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_1_cleanup_jettydir.rb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_1_cleanup_jettydir.rb
index 0dd305a..cdd6b19 100644
--- a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_1_cleanup_jettydir.rb
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_1_cleanup_jettydir.rb
@@ -1,15 +1,15 @@
 directory "FE_tempdir_creation" do
   path "#{ENV['JETTY_BASE']}/temp"
-  owner 'jetty'
-  group 'jetty'
+  owner "#{ENV['JETTY_USER']}"
+  group "#{ENV['JETTY_GROUP']}"
   mode '0755'
   action :create
 end
 
 directory "FE_create_config_dir" do
   path "#{ENV['JETTY_BASE']}/config"
-  owner 'jetty'
-  group 'jetty'
+  owner "#{ENV['JETTY_USER']}"
+  group "#{ENV['JETTY_GROUP']}"
   mode '0755'
   action :create
 end
@@ -17,8 +17,8 @@
 
 directory "FE_create_catalog-fe" do
   path "#{ENV['JETTY_BASE']}/config/catalog-fe"
-  owner 'jetty'
-  group 'jetty'
+  owner "#{ENV['JETTY_USER']}"
+  group "#{ENV['JETTY_GROUP']}"
   mode '0755'
   action :create
 end
@@ -26,8 +26,8 @@
 
 directory "FE_create_catalog-fe" do
   path "#{ENV['JETTY_BASE']}/config/onboarding-fe"
-  owner 'jetty'
-  group 'jetty'
+  owner "#{ENV['JETTY_USER']}"
+  group "#{ENV['JETTY_GROUP']}"
   mode '0755'
   action :create
 end
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb
index 640b5b8..819638a 100644
--- a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb
@@ -1,8 +1,8 @@
 template "catalog-fe-config" do
    path "#{ENV['JETTY_BASE']}/config/catalog-fe/configuration.yaml"
    source "FE-configuration.yaml.erb"
-   owner "jetty"
-   group "jetty"
+   owner "#{ENV['JETTY_USER']}"
+   group "#{ENV['JETTY_GROUP']}"
    mode "0755"
    variables({
       :fe_host_ip   => node['FE_VIP'],
@@ -20,8 +20,8 @@
 cookbook_file "#{ENV['JETTY_BASE']}/config/catalog-fe/workspace-configuration.yaml" do
   source "FE-workspace-configuration.yaml"
   mode 0755
-  owner "jetty"
-  group "jetty"
+  owner "#{ENV['JETTY_USER']}"
+  group "#{ENV['JETTY_GROUP']}"
 end
 
 
@@ -29,7 +29,7 @@
 template "onboarding-fe-config" do
     path "#{ENV['JETTY_BASE']}/config/onboarding-fe/onboarding_configuration.yaml"
     source "FE-onboarding-configuration.yaml.erb"
-    owner "jetty"
-    group "jetty"
+    owner "#{ENV['JETTY_USER']}"
+    group "#{ENV['JETTY_GROUP']}"
     mode "0755"
 end
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_3_errors_config.rb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_3_errors_config.rb
index 54dee2e..aa80879 100644
--- a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_3_errors_config.rb
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_3_errors_config.rb
@@ -1,7 +1,7 @@
 cookbook_file "#{ENV['JETTY_BASE']}/config/catalog-fe/ecomp-error-configuration.yaml" do
   source "FE-ecomp-error-configuration.yaml"
   mode 0755
-  owner "jetty"
-  group "jetty"
+  owner "#{ENV['JETTY_USER']}"
+  group "#{ENV['JETTY_GROUP']}"
 end
  
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_4_logback.rb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_4_logback.rb
index f264183..34c084e 100644
--- a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_4_logback.rb
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_4_logback.rb
@@ -1,6 +1,6 @@
 cookbook_file "#{ENV['JETTY_BASE']}/config/catalog-fe/logback.xml" do
   source "FE-logback.xml"
   mode 0755
-  owner "jetty"
-  group "jetty"
+  owner "#{ENV['JETTY_USER']}"
+  group "#{ENV['JETTY_GROUP']}"
 end
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_5_rest_configuration.rb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_5_rest_configuration.rb
index cf7575c..388974e 100644
--- a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_5_rest_configuration.rb
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_5_rest_configuration.rb
@@ -1,7 +1,7 @@
 cookbook_file "#{ENV['JETTY_BASE']}/config/catalog-fe/rest-configuration-info.yaml" do
   source "FE-rest-configuration.yaml"
   mode 0755
-  owner "jetty"
-  group "jetty"
+  owner "#{ENV['JETTY_USER']}"
+  group "#{ENV['JETTY_GROUP']}"
 end
  
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_6_locate_keystore.rb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_6_locate_keystore.rb
index 527713c..50cb263 100644
--- a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_6_locate_keystore.rb
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_6_locate_keystore.rb
@@ -1,21 +1,21 @@
 directory "Jetty_etcdir_creation" do
 	path "#{ENV['JETTY_BASE']}/etc"
-	owner 'jetty'
-	group 'jetty'
+	owner "#{ENV['JETTY_USER']}"
+	group "#{ENV['JETTY_GROUP']}"
 	mode '0755'
 	action :create
 end
 
 cookbook_file "#{ENV['JETTY_BASE']}/etc/org.onap.sdc.p12" do
    source "org.onap.sdc.p12"
-   owner "jetty"
-   group "jetty"
+   owner "#{ENV['JETTY_USER']}"
+   group "#{ENV['JETTY_GROUP']}"
    mode 0755
 end
 
 cookbook_file "#{ENV['JETTY_BASE']}/etc/org.onap.sdc.trust.jks" do
    source "org.onap.sdc.trust.jks"
-   owner "jetty"
-   group "jetty"
+   owner "#{ENV['JETTY_USER']}"
+   group "#{ENV['JETTY_GROUP']}"
    mode 0755
 end
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_7_create_jetty_modules.rb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_7_create_jetty_modules.rb
index bf756fb..0a1527f 100644
--- a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_7_create_jetty_modules.rb
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_7_create_jetty_modules.rb
@@ -6,22 +6,17 @@
   http_option = "--module=http"
 end
 
-
-bash "create-jetty-modules" do
-cwd "#{ENV['JETTY_BASE']}"
-code <<-EOH
-   cd "#{ENV['JETTY_BASE']}"
-   java -jar "#{ENV['JETTY_HOME']}"/start.jar --add-to-start=deploy
-   java -jar "#{ENV['JETTY_HOME']}"/start.jar --create-startd --add-to-start=http,https,console-capture,setuid
-EOH
+execute "create-jetty-modules" do
+  command "java -jar #{ENV['JETTY_HOME']}/start.jar --add-to-start=deploy && java -jar #{ENV['JETTY_HOME']}/start.jar --create-startd --add-to-start=http,https,console-capture,setuid"
+  cwd "#{ENV['JETTY_BASE']}"
+  action :run
 end
 
-
 template "http-ini" do
    path "#{ENV['JETTY_BASE']}/start.d/http.ini"
    source "http-ini.erb"
-   owner "jetty"
-   group "jetty"
+   owner "#{ENV['JETTY_USER']}"
+   group "#{ENV['JETTY_GROUP']}"
    mode "0755"
    variables({
      :http_option => http_option ,
@@ -33,8 +28,8 @@
 template "https-ini" do
    path "#{ENV['JETTY_BASE']}/start.d/https.ini"
    source "https-ini.erb"
-   owner "jetty"
-   group "jetty"
+   owner "#{ENV['JETTY_USER']}"
+   group "#{ENV['JETTY_GROUP']}"
    mode "0755"
    variables :https_port => "#{node['FE'][:https_port]}"
 end
@@ -43,8 +38,8 @@
 template "ssl-ini" do
    path "#{ENV['JETTY_BASE']}/start.d/ssl.ini"
    source "ssl-ini.erb"
-   owner "jetty"
-   group "jetty"
+   owner "#{ENV['JETTY_USER']}"
+   group "#{ENV['JETTY_GROUP']}"
    mode "0755"
    variables({
      :https_port => "#{node['FE'][:https_port]}" ,
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_8_prepareProbeFile.rb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_8_prepareProbeFile.rb
index 2ce61b9..46bc80a 100644
--- a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_8_prepareProbeFile.rb
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_8_prepareProbeFile.rb
@@ -6,7 +6,7 @@
   port = "#{node['FE'][:http_port]}"
 end
 
-template "/var/lib/jetty/ready-probe.sh" do
+template "#{ENV['JETTY_BASE']}/ready-probe.sh" do
   source "ready-probe.sh.erb"
   sensitive true
   mode 0755
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/ready-probe.sh.erb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/ready-probe.sh.erb
index 5b772ec..eb69f2e 100644
--- a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/ready-probe.sh.erb
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/ready-probe.sh.erb
@@ -1,7 +1,7 @@
-#!/bin/bash
+#!/bin/sh
 health_check_http_code=$(curl -k --max-time 5 -o /dev/null -w '%{http_code}' <%= @protocol %>://127.0.0.1:<%= @port %>/sdc1/rest/healthCheck)
 
-if [[ "$health_check_http_code" -eq 200 ]]; then
+if [ "$health_check_http_code" -eq 200 ]; then
   exit 0
 else
   echo "Health check http status: $health_check_http_code"
diff --git a/catalog-fe/sdc-frontend/startup.sh b/catalog-fe/sdc-frontend/startup.sh
index b2443f1..5a1dd27 100644
--- a/catalog-fe/sdc-frontend/startup.sh
+++ b/catalog-fe/sdc-frontend/startup.sh
@@ -1,18 +1,18 @@
 #!/bin/sh
 
-JAVA_OPTIONS=" ${JAVA_OPTIONS} \
-               -Dconfig.home=${JETTY_BASE}/config \
-               -Dlog.home=${JETTY_BASE}/logs \
-               -Dlogback.configurationFile=${JETTY_BASE}/config/catalog-fe/logback.xml \
-               -Dconfiguration.yaml=${JETTY_BASE}/config/catalog-fe/configuration.yaml \
-               -Donboarding_configuration.yaml=${JETTY_BASE}/config/onboarding-fe/onboarding_configuration.yaml \
-               -Djavax.net.ssl.trustStore=${JETTY_BASE}/etc/org.onap.sdc.trust.jks \
+JAVA_OPTIONS="$JAVA_OPTIONS \
+               -Dconfig.home=$JETTY_BASE/config \
+               -Dlog.home=$JETTY_BASE/logs \
+               -Dlogback.configurationFile=$JETTY_BASE/config/catalog-fe/logback.xml \
+               -Dconfiguration.yaml=$JETTY_BASE/config/catalog-fe/configuration.yaml \
+               -Donboarding_configuration.yaml=$JETTY_BASE/config/onboarding-fe/onboarding_configuration.yaml \
+               -Djavax.net.ssl.trustStore=$JETTY_BASE/etc/org.onap.sdc.trust.jks \
                -Djavax.net.ssl.trustStorePassword=z+KEj;t+,KN^iimSiS89e#p0 \
-               -Djetty.console-capture.dir=${JETTY_BASE}/logs "
+               -Djetty.console-capture.dir=$JETTY_BASE/logs"
 
-cd /var/lib/jetty/chef-solo
+cd $JETTY_BASE/chef-solo
 chef-solo -c solo.rb -E ${ENVNAME}
 
-cd /var/lib/jetty
+cd $JETTY_HOME
 
-java $JAVA_OPTIONS -jar "$JETTY_HOME/start.jar"
+java $JAVA_OPTIONS -jar "${JETTY_HOME}/start.jar"