Reduce size of docker images for APEX-PDP

Avoid creating extra layers when extracting tarball
Remove redundant chown/chmod commands
Reduce size of Alpine image by 25% (853MB to 638MB)
Reduce size of OpenSuse image by 27% (826MB to 606MB)

Issue-ID: POLICY-4272
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: Iebcad1d0b0f784b85a7d1e96c7b8edfd45b27060
diff --git a/packages/apex-pdp-docker/src/main/docker/Dockerfile b/packages/apex-pdp-docker/src/main/docker/Dockerfile
index d8b5477..08bcddb 100644
--- a/packages/apex-pdp-docker/src/main/docker/Dockerfile
+++ b/packages/apex-pdp-docker/src/main/docker/Dockerfile
@@ -20,9 +20,11 @@
 # ============LICENSE_END=========================================================
 #-------------------------------------------------------------------------------
 
-#
-# Docker file to build an image that runs APEX on Java 11 or better in alpine
-#
+FROM busybox AS tarball
+RUN mkdir /packages /extracted
+COPY /maven/apex-pdp-package-full.tar.gz /packages/
+RUN tar xvzf /packages/apex-pdp-package-full.tar.gz --directory /extracted/
+
 FROM onap/policy-jdk-alpine:2.4.3
 
 LABEL maintainer="Policy Team"
@@ -44,20 +46,11 @@
         vim \
         iputils \
     && addgroup -S apexuser && adduser -S apexuser -G apexuser \
-    && mkdir -p $POLICY_HOME \
-    && mkdir -p $POLICY_LOGS \
-    && chown -R apexuser:apexuser $POLICY_LOGS \
-    && mkdir /packages
+    && mkdir -p $POLICY_HOME $POLICY_LOGS \
+    && chown -R apexuser:apexuser $POLICY_HOME $POLICY_LOGS
 
-COPY /maven/apex-pdp-package-full.tar.gz /packages
-RUN tar xvfz /packages/apex-pdp-package-full.tar.gz --directory $POLICY_HOME \
-    && rm /packages/apex-pdp-package-full.tar.gz \
-    && find /opt/app -type d -perm 755 \
-    && find /opt/app -type f -perm 644 \
-    && chmod 755 $POLICY_HOME/bin/* \
-    && cp -pr $POLICY_HOME/examples /home/apexuser \
-    && chown -R apexuser:apexuser /home/apexuser/* $POLICY_HOME \
-    && chmod 755 $POLICY_HOME/etc/*
+COPY --chown=apexuser:apexuser --from=tarball /extracted $POLICY_HOME
+RUN cp -pr $POLICY_HOME/examples /home/apexuser
 
 USER apexuser
 ENV PATH $POLICY_HOME/bin:$PATH