diff options
author | Matej Klotton <matej.klotton@pantheon.tech> | 2019-06-28 17:33:36 +0200 |
---|---|---|
committer | Matej Klotton <matej.klotton@pantheon.tech> | 2019-07-01 13:13:51 +0200 |
commit | c6f21bed9c8144d5195232d28dfd1d1f9f1373e6 (patch) | |
tree | fb67ff910b50bd28ff81e2ab153b9383d0bf3401 | |
parent | 85f914068748d4446b64893b06f7a3abe6cddd6d (diff) |
Reduce CCSDK docker images size
onap/ccsdk-odl-fluorine-alpine-image from 768MB to 526MB
onap/ccsdk-odlsli-alpine-image from 1.36GB to 666MB
Signed-off-by: Matej Klotton <matej.klotton@pantheon.tech>
Change-Id: I80dca08539ea91622ccb00edbe675a0b3203a183
-rw-r--r-- | alpine/src/main/docker/Dockerfile | 2 | ||||
-rw-r--r-- | odlsli/odlsli-alpine/src/main/docker/Dockerfile | 68 | ||||
-rw-r--r-- | opendaylight/fluorine/fluorine-alpine/src/main/docker/Dockerfile | 31 |
3 files changed, 49 insertions, 52 deletions
diff --git a/alpine/src/main/docker/Dockerfile b/alpine/src/main/docker/Dockerfile index 185fab43..6cbceaf4 100644 --- a/alpine/src/main/docker/Dockerfile +++ b/alpine/src/main/docker/Dockerfile @@ -11,4 +11,4 @@ ENV HTTPS_PROXY ${HTTPS_PROXY} ENV https_proxy ${HTTPS_PROXY} # Add tools needed for OpenDaylight -RUN apk update && apk add bash git openjdk8 maven mysql-client nodejs py-pip graphviz unzip rsync nss +RUN apk update && apk --no-cache add bash git openjdk8 maven mysql-client nodejs py-pip graphviz unzip rsync nss diff --git a/odlsli/odlsli-alpine/src/main/docker/Dockerfile b/odlsli/odlsli-alpine/src/main/docker/Dockerfile index 926aa0b5..97c5ae4c 100644 --- a/odlsli/odlsli-alpine/src/main/docker/Dockerfile +++ b/odlsli/odlsli-alpine/src/main/docker/Dockerfile @@ -1,6 +1,27 @@ -# Base ubuntu with added packages needed for open ecomp +# Prepare stage for multistage image build +## START OF STAGE0 ## +FROM ${base.image.name}:${project.docker.latestfulltag.version} AS stage0 + +ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk +ENV ODL_HOME /opt/opendaylight + +# copy the opendaylight credentials +COPY idmlight.db.mv.db $ODL_HOME/data + +# copy CCSDK mvn artifacts to ODL repository +COPY system /tmp/system +RUN rsync -a /tmp/system $ODL_HOME + +# copy deliverables to opt +COPY opt /opt +COPY org.ops4j.pax.logging.cfg $ODL_HOME/etc/org.ops4j.pax.logging.cfg +## END OF STAGE0 ## + + FROM ${base.image.name}:${project.docker.latestfulltag.version} + MAINTAINER CCSDK Team (onap-ccsdk@lists.onap.org) + ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk ENV ODL_HOME /opt/opendaylight ENV SDNC_CONFIG_DIR /opt/onap/ccsdk/data/properties @@ -10,57 +31,22 @@ ENV CCSDK_FEATURES_REPO mvn:org.onap.ccsdk.features/ccsdk-features-all/${ccsdk.f ENV CCSDK_FEATURES_SDNR_WT_REPO mvn:org.onap.ccsdk.features.sdnr.wt/sdnr-wt-feature-aggregator/${ccsdk.features.version}/xml/features ENV CCSDK_SLI_NORTHBOUND_REPO mvn:org.onap.ccsdk.sli.northbound/ccsdk-sli-northbound-all/${ccsdk.sli.northbound.version}/xml/features ENV CCSDK_SLI_PLUGINS_REPO mvn:org.onap.ccsdk.sli.plugins/ccsdk-sli-plugins-all/${ccsdk.sli.plugins.version}/xml/features - ENV ANSIBLE_GPG_KEY ${ansible.gpg.key} ENV ODL_BOOT_FEATURES_EXTRA ${odl.boot.features.extra} -# copy the opendaylight credentials -COPY idmlight.db.mv.db $ODL_HOME/data +# Install sudo and IP utilities +RUN apk update && apk --no-cache add sudo iputils openssl +# Enable wheel group +RUN sed -e 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' -i /etc/sudoers -# copy CCSDK mvn artifacts to ODL repository -COPY system /tmp/system -RUN rsync -a /tmp/system $ODL_HOME && rm -rf /tmp/system +COPY --from=stage0 --chown=odl:odl /opt /opt # Add CCSDK repositories to boot repositories RUN cp $ODL_HOME/etc/org.apache.karaf.features.cfg $ODL_HOME/etc/org.apache.karaf.features.cfg.orig - RUN sed -i -e "\|featuresRepositories|s|$|, ${CCSDK_SLI_CORE_REPO}, ${CCSDK_SLI_ADAPTORS_REPO}, ${CCSDK_SLI_NORTHBOUND_REPO}, ${CCSDK_SLI_PLUGINS_REPO}, ${CCSDK_FEATURES_REPO}|" $ODL_HOME/etc/org.apache.karaf.features.cfg RUN sed -i -e "\|featuresBoot[^a-zA-Z]|s|$|,${ODL_BOOT_FEATURES_EXTRA}|" $ODL_HOME/etc/org.apache.karaf.features.cfg -# Install sudo and IP utilities -RUN apk update && apk add sudo iputils openssl - -# Enable wheel group -RUN sed -e 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' -i /etc/sudoers - -# Create odl user -RUN addgroup -S odl && adduser -S odl -G odl -RUN addgroup odl wheel - -# Install ansible -#COPY ansible-sources.list /etc/apt/sources.list.d -#RUN gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv ${ANSIBLE_GPG_KEY} && \ -# gpg --export --armor ${ANSIBLE_GPG_KEY} | apt-key add - && \ -# apk update && \ -# apk add -y ansible - -# Install ansible-opendaylight -#RUN ansible-galaxy install git+https://git.opendaylight.org/gerrit/integration/packaging/ansible-opendaylight - -# Copy ccsdk install playbook -#COPY install_ccsdk.yml /tmp - -# Install features in ODL -#RUN ansible-playbook -i "localhost," -c local /tmp/install_ccsdk.yml - - -# copy deliverables to opt -COPY --chown=odl:odl opt /opt -COPY --chown=odl:odl org.ops4j.pax.logging.cfg /opt/opendaylight/etc/org.ops4j.pax.logging.cfg - -RUN chown -R odl:odl /opt - USER odl ENTRYPOINT /opt/onap/ccsdk/bin/startODL.sh EXPOSE 8181 diff --git a/opendaylight/fluorine/fluorine-alpine/src/main/docker/Dockerfile b/opendaylight/fluorine/fluorine-alpine/src/main/docker/Dockerfile index a043e1e9..b5e91b92 100644 --- a/opendaylight/fluorine/fluorine-alpine/src/main/docker/Dockerfile +++ b/opendaylight/fluorine/fluorine-alpine/src/main/docker/Dockerfile @@ -1,18 +1,29 @@ -# Base ubuntu with added packages needed for open ecomp +# Prepare stage for multistage image build +## START OF STAGE0 ## +FROM onap/ccsdk-alpine-image:${project.docker.latestfulltag.version} AS stage0 + +# Add the opendaylight's karaf and expand +ADD karaf-${ccsdk.opendaylight.version}.tar.gz /opt/odl +RUN mv /opt/odl/karaf-${ccsdk.opendaylight.version} /opt/opendaylight \ + && ln -s /opt/opendaylight /opt/opendaylight/karaf-${ccsdk.opendaylight.version} \ + && ln -s /opt/opendaylight /opt/opendaylight/current \ + && rmdir /opt/odl +## END OF STAGE0 ## + + FROM onap/ccsdk-alpine-image:${project.docker.latestfulltag.version} + MAINTAINER CCSDK Team (onap-ccsdk@lists.onap.org) + ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk ENV ODL_HOME /opt/opendaylight/current -# copy the opendaylight tar and expand -COPY karaf-${ccsdk.opendaylight.version}.tar.gz /tmp/ -RUN mkdir -p /opt/odl \ - && tar zxvf /tmp/karaf-${ccsdk.opendaylight.version}.tar.gz --directory /opt/odl \ - && rm -rf /tmp/karaf-${ccsdk.opendaylight.version}.tar.gz \ - && mv /opt/odl/karaf-${ccsdk.opendaylight.version} /opt/opendaylight \ - && ln -s /opt/opendaylight /opt/opendaylight/karaf-${ccsdk.opendaylight.version} \ - && ln -s /opt/opendaylight /opt/opendaylight/current - +# Create odl user +RUN addgroup -S odl +RUN adduser -S odl -G odl +RUN addgroup odl wheel + +COPY --from=stage0 --chown=odl:odl /opt /opt # workaround till we get proxy working RUN mkdir -p /opt/opendaylight/system/org/mariadb/jdbc/mariadb-java-client/${ccsdk.mariadb-connector-java.version} |