Reduce size of docker images for CLAMP
Avoid creating extra layers when extracting tarball
Remove redundant chown commands
Reduce sizes of Alpine images by 27%
Reduce sizes of OpenSuse images by 20%
Issue-ID: POLICY-4277
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: If772bb944864d404ceba5ff66be7d613128835a1
diff --git a/packages/policy-clamp-docker/src/main/docker/PolicyParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/PolicyParticipant.Dockerfile
index f259492..8495974 100644
--- a/packages/policy-clamp-docker/src/main/docker/PolicyParticipant.Dockerfile
+++ b/packages/policy-clamp-docker/src/main/docker/PolicyParticipant.Dockerfile
@@ -18,9 +18,11 @@
# ============LICENSE_END=========================================================
#-------------------------------------------------------------------------------
-#
-# Docker file to build an image that runs the CLAMP ACM Policy Framework Participant on Java 11 or better in alpine
-#
+FROM busybox AS tarball
+RUN mkdir /packages /extracted
+COPY /maven/lib/policy-participant.tar.gz /packages/
+RUN tar xvzf /packages/policy-participant.tar.gz --directory /extracted/
+
FROM onap/policy-jre-alpine:2.4.3
LABEL maintainer="Policy Team"
@@ -38,21 +40,16 @@
ENV POLICY_LOGS=$POLICY_LOGS
ENV POLICY_HOME=$POLICY_HOME/clamp
-RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \
- chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \
- mkdir /packages
-COPY /maven/lib/policy-participant.tar.gz /packages
+RUN mkdir -p $POLICY_HOME $POLICY_LOGS && \
+ chown -R policy:policy $POLICY_HOME $POLICY_LOGS
-RUN tar xvfz /packages/policy-participant.tar.gz --directory $POLICY_HOME && \
- rm /packages/policy-participant.tar.gz
+COPY --chown=policy:policy --from=tarball /extracted $POLICY_HOME
WORKDIR $POLICY_HOME
-COPY policy-participant.sh bin/.
-COPY /maven/policy-clamp-participant-impl-policy.jar /app/app.jar
+COPY --chown=policy:policy policy-participant.sh bin/
+COPY --chown=policy:policy /maven/policy-clamp-participant-impl-policy.jar /app/app.jar
-RUN chown -R policy:policy * && \
- chmod 755 bin/*.sh && \
- chown -R policy:policy /app
+RUN chmod 755 bin/*.sh
EXPOSE 8085