Run pods as non-root user

Summary of changes:
sdc-cassandra-init
	Added user sdc (in base image base_sdc-cqlsh - https://gerrit.onap.org/r/103436)
	Run entrypoint as user sdc
	Moved relevant files from /root/ to /home/sdc/

sdc-backend-init
	Added user sdc (in base image base_sdc-python - https://gerrit.onap.org/r/103436)
	Run entrypoint as user sdc
	Moved relevant files from /root/ to /home/sdc/

sdc-backend
	Run entrypoint as user jetty
	Moved relevant files from /root/ to /var/lib/jetty/
	Moved cadi & cert files from /opt/app/jetty to /var/lib/jetty/
	Moved ready_probe from /var/lib/read-probe.sh to /var/lib/jetty/read-probe.sh

sdc-frontend
	Run entrypoint as user jetty
	Moved relevant files from /root/ to /var/lib/jetty/
	Moved ready_probe from /var/lib/read-probe.sh to /var/lib/jetty/read-probe.sh

sdc-onboard-backend-docker
	Run entrypoint as user jetty
	Moved relevant files from /root/ to /var/lib/jetty/
	Moved ready_probe from /var/lib/read-probe.sh to /var/lib/jetty/read-probe.sh

sdc-onboard-db-init-docker
	Run entrypoint as user sdc
	Added user sdc (in base image base_sdc-cqlsh - https://gerrit.onap.org/r/103436)
	Moved relevant files from /root/ to /home/sdc/

Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-2798
Change-Id: I85be320a4a5e1cc5aeebbb98c4484d5d6fd06dfc
diff --git a/catalog-be/sdc-backend/Dockerfile b/catalog-be/sdc-backend/Dockerfile
index 104bbd9..833008d 100644
--- a/catalog-be/sdc-backend/Dockerfile
+++ b/catalog-be/sdc-backend/Dockerfile
@@ -1,16 +1,13 @@
 FROM onap/base_sdc-jetty:1.6.0
-
-COPY chef-solo /root/chef-solo/
-
-COPY chef-repo/cookbooks/. /root/chef-solo/cookbooks/
+ 
+COPY --chown=jetty:jetty chef-solo ${JETTY_BASE}/chef-solo/
+COPY --chown=jetty:jetty chef-repo/cookbooks/. ${JETTY_BASE}/chef-solo/cookbooks/
 
 ADD --chown=jetty:jetty catalog-be-*.war       ${JETTY_BASE}/webappwar/
 ADD --chown=jetty:jetty context.xml       ${JETTY_BASE}/webapps/
 
-USER root
+COPY --chown=jetty:jetty startup.sh ${JETTY_BASE}/ 
 
-COPY startup.sh /root/
+RUN chmod 770 ${JETTY_BASE}/startup.sh
 
-RUN chmod 770 /root/startup.sh
-
-ENTRYPOINT [ "/root/startup.sh" ]
+ENTRYPOINT ${JETTY_BASE}/startup.sh
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/cadi.properties b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/cadi.properties
index 2d234c3..1011ba3 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/cadi.properties
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/cadi.properties
@@ -1,4 +1,4 @@
 #############################################################
 # This file should be replaced with jetty cadi.properties:  #
-#  /opt/app/jetty/base/be/etc/cadi.properties               #
-#############################################################
\ No newline at end of file
+#  /var/lib/jetty/base/be/etc/cadi.properties               #
+#############################################################
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/cadi_truststore.jks b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/cadi_truststore.jks
index 6720910..0835ef4 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/cadi_truststore.jks
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/cadi_truststore.jks
@@ -1,4 +1,4 @@
 ##################################################################
 ## This file should be replaced with jetty cadi_truststore.jks:  #
-##  /opt/app/jetty/base/be/etc/cadi_truststore.jks               #
-##################################################################
\ No newline at end of file
+##  /var/lib/jetty/base/be/etc/cadi_truststore.jks               #
+##################################################################
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/keyfile b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/keyfile
index 41876b7..43d20d4 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/keyfile
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/keyfile
@@ -1,4 +1,4 @@
 #############################################################
 # This file should be replaced with jetty keyfile:          #
-#  /opt/app/jetty/base/be/etc/keyfile                       #
-#############################################################
\ No newline at end of file
+#  /var/lib/jetty/base/be/etc/keyfile                       #
+#############################################################
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_10_setup_cadi.rb b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_10_setup_cadi.rb
index b06f8a5..3a79cfc 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_10_setup_cadi.rb
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_10_setup_cadi.rb
@@ -35,51 +35,3 @@
   mode "0755"
 end
 
-
-#Workaround due to hardcode definition in cata,log-be web.xml file
-directory "/opt/app/jetty" do
-  path "/opt/app/jetty"
-  owner 'jetty'
-  group 'jetty'
-  mode '0755'
-  recursive true
-  action :create
-end
-
-directory "/opt/app/jetty/base/" do
-  path "/opt/app/jetty/base/"
-  owner 'jetty'
-  group 'jetty'
-  mode '0755'
-  recursive true
-  action :create
-end
-
-
-directory "/opt/app/jetty/base/be/" do
-  path "/opt/app/jetty/base/be/"
-  owner 'jetty'
-  group 'jetty'
-  mode '0755'
-  recursive true
-  action :create
-end
-
-directory "/opt/app/jetty/base/be/etc" do
-  path "/opt/app/jetty/base/be/etc"
-  owner 'jetty'
-  group 'jetty'
-  mode '0755'
-  recursive true
-  action :create
-end
-
-#Workaround due to hardcode definition in catalog-be web.xml file
-template "/opt/app/jetty/base/be/etc/cadi.properties" do
-  path "/opt/app/jetty/base/be/etc/cadi.properties"
-  source "cadi.properties.erb"
-  owner "jetty"
-  group "jetty"
-  mode "0755"
-end
-
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_9_prepareProbeFile.rb b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_9_prepareProbeFile.rb
index 8d42c26..81e1a85 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_9_prepareProbeFile.rb
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_9_prepareProbeFile.rb
@@ -6,7 +6,7 @@
   port = "#{node['BE'][:http_port]}"
 end
 
-template "/var/lib/ready-probe.sh" do
+template "/var/lib/jetty/ready-probe.sh" do
   source "ready-probe.sh.erb"
   sensitive true
   mode 0755
@@ -14,4 +14,4 @@
     :protocol => protocol,
     :port => port
   })
-end
\ No newline at end of file
+end
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-distribution-engine-configuration.yaml.erb b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-distribution-engine-configuration.yaml.erb
index a9df5c3..0fa6936 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-distribution-engine-configuration.yaml.erb
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-distribution-engine-configuration.yaml.erb
@@ -58,7 +58,7 @@
          readTimeoutMs: 5000
          connectTimeoutMs: 1000
       clientCertificate:
-         keyStore: /opt/app/jetty/base/be/etc/non-prod.jks
+         keyStore: /var/lib/jetty/base/be/etc/non-prod.jks
          keyStorePassword: hmXYcznAljMSisdy8zgcag==
       headers:
          X-FromAppId: asdc
diff --git a/catalog-be/sdc-backend/startup.sh b/catalog-be/sdc-backend/startup.sh
index e41aff4..abb3074 100644
--- a/catalog-be/sdc-backend/startup.sh
+++ b/catalog-be/sdc-backend/startup.sh
@@ -11,7 +11,7 @@
        -Djetty.console-capture.dir=${JETTY_BASE}/logs \
        ${JAVA_OPTIONS} "
 
-cd /root/chef-solo
+cd /var/lib/jetty/chef-solo
 chef-solo -c solo.rb -E ${ENVNAME}
 
 status=$?