diff options
author | danielhanrahan <daniel.hanrahan@est.tech> | 2022-07-11 18:14:13 +0100 |
---|---|---|
committer | danielhanrahan <daniel.hanrahan@est.tech> | 2022-07-13 12:37:25 +0100 |
commit | cd21359e340ef8e8b8ff0c9c2b9cd385b02de506 (patch) | |
tree | 74bc47731bbff5f69c294df8f4967430e101c949 /packages/policy-clamp-docker/src | |
parent | d0db79ad9ae0446bba6b5f5dbc6f51c34d7fb4d2 (diff) |
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
Diffstat (limited to 'packages/policy-clamp-docker/src')
8 files changed, 90 insertions, 119 deletions
diff --git a/packages/policy-clamp-docker/src/main/docker/AcmRuntime-Suse.Dockerfile b/packages/policy-clamp-docker/src/main/docker/AcmRuntime-Suse.Dockerfile index a521d0425..992735855 100644 --- a/packages/policy-clamp-docker/src/main/docker/AcmRuntime-Suse.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/AcmRuntime-Suse.Dockerfile @@ -18,9 +18,11 @@ # ============LICENSE_END========================================================= #------------------------------------------------------------------------------- -# -# Docker file to build an image that runs the CLAMP ACM runtime on Java 11 or better in OpenSuse -# +FROM busybox AS tarball +RUN mkdir /packages /extracted +COPY /maven/lib/policy-clamp-runtime-acm.tar.gz /packages/ +RUN tar xvzf /packages/policy-clamp-runtime-acm.tar.gz --directory /extracted/ + FROM opensuse/leap:15.4 LABEL maintainer="Policy Team" @@ -40,26 +42,20 @@ ENV POLICY_HOME=/opt/app/policy/clamp ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 ENV JAVA_HOME=/usr/lib64/jvm/java-11-openjdk-11 -RUN zypper -n -q install --no-recommends gzip java-11-openjdk-headless netcat-openbsd tar && \ +RUN zypper -n -q install --no-recommends java-11-openjdk-headless netcat-openbsd && \ zypper -n -q update && zypper -n -q clean --all && \ groupadd --system policy && \ useradd --system --shell /bin/sh -G policy policy && \ - mkdir -p /app $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \ - chown -R policy:policy /app $POLICY_HOME $POLICY_LOGS && \ - mkdir /packages - -COPY /maven/lib/policy-clamp-runtime-acm.tar.gz /packages + mkdir -p $POLICY_HOME $POLICY_LOGS && \ + chown -R policy:policy $POLICY_HOME $POLICY_LOGS -RUN tar xvfz /packages/policy-clamp-runtime-acm.tar.gz --directory $POLICY_HOME && \ - rm /packages/policy-clamp-runtime-acm.tar.gz +COPY --chown=policy:policy --from=tarball /extracted $POLICY_HOME WORKDIR $POLICY_HOME -COPY acm-runtime.sh bin/. -COPY /maven/policy-clamp-runtime-acm.jar /app/app.jar +COPY --chown=policy:policy acm-runtime.sh bin/ +COPY --chown=policy:policy /maven/policy-clamp-runtime-acm.jar /app/app.jar -RUN chown -R policy:policy * && \ - chmod 755 bin/*.sh && \ - chown -R policy:policy /app +RUN chmod 755 bin/*.sh EXPOSE 6969 diff --git a/packages/policy-clamp-docker/src/main/docker/AcmRuntime.Dockerfile b/packages/policy-clamp-docker/src/main/docker/AcmRuntime.Dockerfile index 2dd1083af..914c9659b 100644 --- a/packages/policy-clamp-docker/src/main/docker/AcmRuntime.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/AcmRuntime.Dockerfile @@ -18,9 +18,11 @@ # ============LICENSE_END========================================================= #------------------------------------------------------------------------------- -# -# Docker file to build an image that runs the CLAMP ACM runtime on Java 11 or better in alpine -# +FROM busybox AS tarball +RUN mkdir /packages /extracted +COPY /maven/lib/policy-clamp-runtime-acm.tar.gz /packages/ +RUN tar xvzf /packages/policy-clamp-runtime-acm.tar.gz --directory /extracted/ + FROM onap/policy-jre-alpine:2.4.3 LABEL maintainer="Policy Team" @@ -38,21 +40,16 @@ ARG POLICY_LOGS=/var/log/onap/policy/policy-clamp-runtime-acm 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-clamp-runtime-acm.tar.gz /packages +RUN mkdir -p $POLICY_HOME $POLICY_LOGS && \ + chown -R policy:policy $POLICY_HOME $POLICY_LOGS -RUN tar xvfz /packages/policy-clamp-runtime-acm.tar.gz --directory $POLICY_HOME && \ - rm /packages/policy-clamp-runtime-acm.tar.gz +COPY --chown=policy:policy --from=tarball /extracted $POLICY_HOME WORKDIR $POLICY_HOME -COPY acm-runtime.sh bin/. -COPY /maven/policy-clamp-runtime-acm.jar /app/app.jar +COPY --chown=policy:policy acm-runtime.sh bin/ +COPY --chown=policy:policy /maven/policy-clamp-runtime-acm.jar /app/app.jar -RUN chown -R policy:policy * && \ - chmod 755 bin/*.sh && \ - chown -R policy:policy /app +RUN chmod 755 bin/*.sh EXPOSE 6969 diff --git a/packages/policy-clamp-docker/src/main/docker/HttpParticipant-Suse.Dockerfile b/packages/policy-clamp-docker/src/main/docker/HttpParticipant-Suse.Dockerfile index 7d331817b..9e8333a0e 100644 --- a/packages/policy-clamp-docker/src/main/docker/HttpParticipant-Suse.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/HttpParticipant-Suse.Dockerfile @@ -18,9 +18,11 @@ # ============LICENSE_END========================================================= #------------------------------------------------------------------------------- -# -# Docker file to build an image that runs the CLAMP ACM HTTP Participant on Java 11 or better in OpenSuse -# +FROM busybox AS tarball +RUN mkdir /packages /extracted +COPY /maven/lib/http-participant.tar.gz /packages/ +RUN tar xvzf /packages/http-participant.tar.gz --directory /extracted/ + FROM opensuse/leap:15.4 LABEL maintainer="Policy Team" @@ -40,26 +42,20 @@ ENV POLICY_HOME=/opt/app/policy/clamp ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 ENV JAVA_HOME=/usr/lib64/jvm/java-11-openjdk-11 -RUN zypper -n -q install --no-recommends gzip java-11-openjdk-headless netcat-openbsd tar && \ +RUN zypper -n -q install --no-recommends java-11-openjdk-headless netcat-openbsd && \ zypper -n -q update && zypper -n -q clean --all && \ groupadd --system policy && \ useradd --system --shell /bin/sh -G policy policy && \ - mkdir -p /app $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \ - chown -R policy:policy /app $POLICY_HOME $POLICY_LOGS && \ - mkdir /packages - -COPY /maven/lib/http-participant.tar.gz /packages + mkdir -p $POLICY_HOME $POLICY_LOGS && \ + chown -R policy:policy $POLICY_HOME $POLICY_LOGS -RUN tar xvfz /packages/http-participant.tar.gz --directory $POLICY_HOME && \ - rm /packages/http-participant.tar.gz +COPY --chown=policy:policy --from=tarball /extracted $POLICY_HOME WORKDIR $POLICY_HOME -COPY http-participant.sh bin/. -COPY /maven/policy-clamp-participant-impl-http.jar /app/app.jar +COPY --chown=policy:policy http-participant.sh bin/ +COPY --chown=policy:policy /maven/policy-clamp-participant-impl-http.jar /app/app.jar -RUN chown -R policy:policy * && \ - chmod 755 bin/*.sh && \ - chown -R policy:policy /app +RUN chmod 755 bin/*.sh EXPOSE 8084 diff --git a/packages/policy-clamp-docker/src/main/docker/HttpParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/HttpParticipant.Dockerfile index 470178b89..4479f7923 100644 --- a/packages/policy-clamp-docker/src/main/docker/HttpParticipant.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/HttpParticipant.Dockerfile @@ -18,9 +18,10 @@ # ============LICENSE_END========================================================= #------------------------------------------------------------------------------- -# -# Docker file to build an image that runs the CLAMP ACM HTTP Participant on Java 11 or better in alpine -# +FROM busybox AS tarball +RUN mkdir /packages /extracted +COPY /maven/lib/http-participant.tar.gz /packages/ +RUN tar xvzf /packages/http-participant.tar.gz --directory /extracted/ FROM onap/policy-jre-alpine:2.4.3 @@ -39,21 +40,16 @@ ARG POLICY_LOGS=/var/log/onap/policy/http-participant 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/http-participant.tar.gz /packages +RUN mkdir -p $POLICY_LOGS $POLICY_HOME && \ + chown -R policy:policy $POLICY_HOME $POLICY_LOGS -RUN tar xvfz /packages/http-participant.tar.gz --directory $POLICY_HOME && \ - rm /packages/http-participant.tar.gz +COPY --chown=policy:policy --from=tarball /extracted $POLICY_HOME WORKDIR $POLICY_HOME -COPY http-participant.sh bin/. -COPY /maven/policy-clamp-participant-impl-http.jar /app/app.jar +COPY --chown=policy:policy http-participant.sh bin/ +COPY --chown=policy:policy /maven/policy-clamp-participant-impl-http.jar /app/app.jar -RUN chown -R policy:policy * && \ - chmod 755 bin/*.sh && \ - chown -R policy:policy /app +RUN chmod 755 bin/*.sh EXPOSE 8084 diff --git a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant-Suse.Dockerfile b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant-Suse.Dockerfile index 3d201c988..ae3ab9fc1 100644 --- a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant-Suse.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant-Suse.Dockerfile @@ -18,9 +18,11 @@ # ============LICENSE_END========================================================= #------------------------------------------------------------------------------- -# -# Docker file to build an image that runs the CLAMP ACM K8S Participant on Java 11 or better in OpenSuse -# +FROM busybox AS tarball +RUN mkdir /packages /extracted +COPY /maven/lib/kubernetes-participant.tar.gz /packages/ +RUN tar xvzf /packages/kubernetes-participant.tar.gz --directory /extracted/ + FROM opensuse/leap:15.4 LABEL maintainer="Policy Team" @@ -44,22 +46,16 @@ RUN zypper -n -q install --no-recommends gzip java-11-openjdk-headless netcat-op zypper -n -q update && zypper -n -q clean --all && \ groupadd --system policy && \ useradd --system --shell /bin/sh -G policy policy && \ - mkdir -p /app $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \ - chown -R policy:policy /app $POLICY_HOME $POLICY_LOGS && \ - mkdir /packages - -COPY /maven/lib/kubernetes-participant.tar.gz /packages + mkdir -p /app $POLICY_HOME $POLICY_LOGS && \ + chown -R policy:policy /app $POLICY_HOME $POLICY_LOGS -RUN tar xvfz /packages/kubernetes-participant.tar.gz --directory $POLICY_HOME && \ - rm /packages/kubernetes-participant.tar.gz +COPY --chown=policy:policy --from=tarball /extracted $POLICY_HOME WORKDIR $POLICY_HOME -COPY kubernetes-participant.sh bin/. -COPY /maven/policy-clamp-participant-impl-kubernetes.jar /app/app.jar +COPY --chown=policy:policy kubernetes-participant.sh bin/ +COPY --chown=policy:policy /maven/policy-clamp-participant-impl-kubernetes.jar /app/app.jar -RUN chown -R policy:policy * && \ - chmod 755 bin/*.sh && \ - chown -R policy:policy /app && \ +RUN chmod 755 bin/*.sh && \ wget https://get.helm.sh/helm-v3.5.2-linux-amd64.tar.gz && \ tar xvf helm-v3.5.2-linux-amd64.tar.gz && \ mv linux-amd64/helm /usr/local/bin && \ diff --git a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant.Dockerfile index 76b11119b..4a1833277 100644 --- a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipant.Dockerfile @@ -18,9 +18,11 @@ # ============LICENSE_END========================================================= #------------------------------------------------------------------------------- -# -# Docker file to build an image that runs the CLAMP ACM K8S Participant on Java 11 or better in alpine -# +FROM busybox AS tarball +RUN mkdir /packages /extracted +COPY /maven/lib/kubernetes-participant.tar.gz /packages/ +RUN tar xvzf /packages/kubernetes-participant.tar.gz --directory /extracted/ + FROM onap/policy-jre-alpine:2.4.3 LABEL maintainer="Policy Team" @@ -38,21 +40,16 @@ ARG POLICY_LOGS=/var/log/onap/policy/k8s-participant 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/kubernetes-participant.tar.gz /packages +RUN mkdir -p $POLICY_HOME $POLICY_LOGS && \ + chown -R policy:policy $POLICY_HOME $POLICY_LOGS -RUN tar xvfz /packages/kubernetes-participant.tar.gz --directory $POLICY_HOME && \ - rm /packages/kubernetes-participant.tar.gz +COPY --chown=policy:policy --from=tarball /extracted $POLICY_HOME WORKDIR $POLICY_HOME -COPY kubernetes-participant.sh bin/. -COPY /maven/policy-clamp-participant-impl-kubernetes.jar /app/app.jar +COPY --chown=policy:policy kubernetes-participant.sh bin/ +COPY --chown=policy:policy /maven/policy-clamp-participant-impl-kubernetes.jar /app/app.jar -RUN chown -R policy:policy * && \ - chmod 755 bin/*.sh && \ - chown -R policy:policy /app && \ +RUN chmod 755 bin/*.sh && \ apk update && \ apk add wget && \ wget https://get.helm.sh/helm-v3.5.2-linux-amd64.tar.gz && \ diff --git a/packages/policy-clamp-docker/src/main/docker/PolicyParticipant-Suse.Dockerfile b/packages/policy-clamp-docker/src/main/docker/PolicyParticipant-Suse.Dockerfile index f08a0035d..6373ddf97 100644 --- a/packages/policy-clamp-docker/src/main/docker/PolicyParticipant-Suse.Dockerfile +++ b/packages/policy-clamp-docker/src/main/docker/PolicyParticipant-Suse.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 OpenSuse -# +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 opensuse/leap:15.4 LABEL maintainer="Policy Team" @@ -40,26 +42,20 @@ ENV POLICY_HOME=/opt/app/policy/clamp ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 ENV JAVA_HOME=/usr/lib64/jvm/java-11-openjdk-11 -RUN zypper -n -q install --no-recommends gzip java-11-openjdk-headless netcat-openbsd tar && \ +RUN zypper -n -q install --no-recommends java-11-openjdk-headless netcat-openbsd && \ zypper -n -q update && zypper -n -q clean --all && \ groupadd --system policy && \ useradd --system --shell /bin/sh -G policy policy && \ - mkdir -p /app $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \ - chown -R policy:policy /app $POLICY_HOME $POLICY_LOGS && \ - mkdir /packages - -COPY /maven/lib/policy-participant.tar.gz /packages + 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 diff --git a/packages/policy-clamp-docker/src/main/docker/PolicyParticipant.Dockerfile b/packages/policy-clamp-docker/src/main/docker/PolicyParticipant.Dockerfile index f25949253..8495974d8 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 @@ ARG POLICY_LOGS=/var/log/onap/policy/pf-participant 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 |