summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2022-07-01 15:11:06 +0100
committerdanielhanrahan <daniel.hanrahan@est.tech>2022-07-13 10:29:45 +0100
commitc0f36b8da4898e2e2b52b74e02da95a6588fe2b8 (patch)
tree02595e0986abccb862aefdffee18858f610b570e /packages
parent776254df238c22646dee241534d356ae7552f0b2 (diff)
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
Diffstat (limited to 'packages')
-rw-r--r--packages/apex-pdp-docker/src/main/docker/Dockerfile25
-rw-r--r--packages/apex-pdp-docker/src/main/docker/suse.Dockerfile27
2 files changed, 19 insertions, 33 deletions
diff --git a/packages/apex-pdp-docker/src/main/docker/Dockerfile b/packages/apex-pdp-docker/src/main/docker/Dockerfile
index d8b547760..08bcddb05 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 @@ RUN apk update \
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
diff --git a/packages/apex-pdp-docker/src/main/docker/suse.Dockerfile b/packages/apex-pdp-docker/src/main/docker/suse.Dockerfile
index 5de782e4c..d947a3cc7 100644
--- a/packages/apex-pdp-docker/src/main/docker/suse.Dockerfile
+++ b/packages/apex-pdp-docker/src/main/docker/suse.Dockerfile
@@ -18,9 +18,11 @@
# ============LICENSE_END=========================================================
#-------------------------------------------------------------------------------
-#
-# Docker file to build an image that runs APEX on Java 11 or better in OpenSuse
-#
+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 opensuse/leap:15.4
LABEL maintainer="Policy Team"
@@ -39,23 +41,14 @@ ENV POLICY_LOGS=$POLICY_LOGS
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-devel netcat-openbsd tar \
+RUN zypper -n -q install --no-recommends java-11-openjdk-devel netcat-openbsd \
&& zypper -n -q update && zypper -n -q clean --all \
&& groupadd --system apexuser && useradd --system --shell /bin/sh -G apexuser apexuser \
- && mkdir -p $POLICY_HOME \
- && mkdir -p $POLICY_LOGS \
- && chown -R apexuser:apexuser $POLICY_HOME $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