why build when you can download

Change-Id: I1171418d892ad93b4d5c6d0eebcfd5941ec895aa
diff --git a/docker/Dockerfile.onos b/docker/Dockerfile.onos
index 8202767..bb12c15 100644
--- a/docker/Dockerfile.onos
+++ b/docker/Dockerfile.onos
@@ -1,87 +1,54 @@
-FROM sgrio/java-oracle:jdk_8 as build
-
-# Install and configure build tools
-ENV JAVA_OPTS="${JAVA_OPTS:--DenableOFTLS=true -Djavax.net.ssl.keyStore=/home/sdn/wiki/onos.jks -Djavax.net.ssl.keyStorePassword=222222 -Djavax.net.ssl.trustStore=/home/sdn/wiki/onos.jks -Djavax.net.ssl.trustStorePassword=222222}"
-
-RUN apt-get update && apt-get install -y git unzip maven curl python
-RUN curl -sSL http://commondatastorage.googleapis.com/git-repo-downloads/repo -o /bin/repo && chmod 755 /bin/repo
-
-# The ENV settings for ONOS, KARAF_VERSION, KARAF_ROOT, KARAF_M2, and APPS_ROOT
-# must be replicated below to the final image as they are shared between stages
-ENV ONOS=/root/onos
-ENV APPS_ROOT=${ONOS}/apps
-ENV KARAF_VERSION=3.0.8
-ENV KARAF_ROOT=${ONOS}/apache-karaf-${KARAF_VERSION}
-ENV KARAF_M2=${KARAF_ROOT}/system
-ENV MANIFEST_BRANCH=master
-ENV BUILD_ROOT=/build
-ENV APP_INSTALL_ROOT=/expand
-
-# Build the applications
-RUN mkdir -p ${BUILD_ROOT}
-WORKDIR ${BUILD_ROOT}
-RUN repo init -u http://gerrit.opencord.org/manifest -b ${MANIFEST_BRANCH} -g onos && repo sync
-WORKDIR ${BUILD_ROOT}/onos-apps/apps
-RUN mvn -DskipTests=true clean install
-
-FROM onosproject/onos:1.10.3 as integration
+FROM maven:3-jdk-8-alpine as download
 MAINTAINER Open Networking Foundation <info@opennetworking.org>
 
-# The ENV settings for ONOS, KARAF_VERSION, KARAF_ROOT, KARAF_M2, and APPS_ROOT
-# must be replicated below to the final image as they are shared between stages
+#RUN apt-get update && apt-get install -y maven
+
+# The ENV settings must be replicated below as they are not shared between stages
+ENV DOWNLOAD_ROOT=/download
+
+# Build the applications
+RUN mkdir -p ${DOWNLOAD_ROOT}
+WORKDIR ${DOWNLOAD_ROOT}
+ADD config/dependencies.xml .
+RUN mvn dependency:copy -Dmdep.useBaseVersion=true -DoutputDirectory=${DOWNLOAD_ROOT} -Dsilent=true -f dependencies.xml
+
+FROM onosproject/onos:1.10.3 as install
+MAINTAINER Open Networking Foundation <info@opennetworking.org>
+
+# The ENV settings must be replicated below as they are not shared between stages
 ENV ONOS=/root/onos
-ENV APPS_ROOT=${ONOS}/apps
 ENV KARAF_VERSION=3.0.8
 ENV KARAF_ROOT=${ONOS}/apache-karaf-${KARAF_VERSION}
+ENV APPS_ROOT=${ONOS}/apps
 ENV KARAF_M2=${KARAF_ROOT}/system
-ENV MANIFEST_BRANCH=master
-ENV BUILD_ROOT=/build
+ENV DOWNLOAD_ROOT=/download
 ENV APP_INSTALL_ROOT=/expand
 
-copy --from=build /build /build
-
-# Specify application versions to install
-ENV AAA_VERSION=1.3.0-SNAPSHOT \
-	CONFIG_VERSION=1.3.0-SNAPSHOT \
-	IGMP_VERSION=1.3.0-SNAPSHOT \
-	IGMP_PROXY_VERSION=1.1.0-SNAPSHOT \
-	MCAST_VERSION=1.3.0-SNAPSHOT \
-	OLT_VERSION=1.3.0-SNAPSHOT \
-	SADIS_VERSION=1.1.0-SNAPSHOT \
-	VTN_VERSION=1.3.0-SNAPSHOT \
-	L2_DHCP_RELAY_VERSION=1.1.0-SNAPSHOT
-
-ENV APPS="aaa-${AAA_VERSION} \
-	cord-config-${CONFIG_VERSION} \
-	igmp-${IGMP_VERSION} \
-	mcast-${MCAST_VERSION} \
-	olt-app-${OLT_VERSION} \
-	sadis-app-${SADIS_VERSION} \
-	vtn-${VTN_VERSION} \
-        aaa-${AAA_VERSION} \
-        onos-app-igmpproxy-${IGMP_PROXY_VERSION} \
-	dhcpl2relay-${L2_DHCP_RELAY_VERSION}"
+# Copy the downloaded artifact to the install stage container
+COPY --from=download ${DOWNLOAD_ROOT} ${DOWNLOAD_ROOT}
 
 # Install the applications
-COPY config/app-install.sh .
+COPY config/app-install.sh ./app-install.sh
 RUN chmod 755 ./app-install.sh
 RUN ./app-install.sh
 
 # Create the final image coping over the installed applications from the build stage
 FROM onosproject/onos:1.10.3
+MAINTAINER Open Networking Foundation <info@opennetworking.org>
 
 # Install Key Store Options
 ENV JAVA_OPTS="${JAVA_OPTS:--DenableOFTLS=true -Djavax.net.ssl.keyStore=/home/sdn/wiki/onos.jks -Djavax.net.ssl.keyStorePassword=222222 -Djavax.net.ssl.trustStore=/home/sdn/wiki/onos.jks -Djavax.net.ssl.trustStorePassword=222222}"
 
+# The ENV settings must be replicated below as they are not shared between stages
 ENV ONOS=/root/onos
 ENV KARAF_VERSION=3.0.8
 ENV KARAF_ROOT=${ONOS}/apache-karaf-${KARAF_VERSION}
 ENV KARAF_M2=${KARAF_ROOT}/system
 ENV APPS_ROOT=${ONOS}/apps
 
-COPY --from=integration ${KARAF_M2}/ ${KARAF_M2}/
+COPY --from=install ${KARAF_M2}/ ${KARAF_M2}/
 RUN echo "${KARAF_M2} ${APPS_ROOT}"
-COPY --from=integration ${APPS_ROOT}/ ${APPS_ROOT}/
+COPY --from=install ${APPS_ROOT}/ ${APPS_ROOT}/
 COPY config/netcfg.json $KARAF_ROOT/../config/network-cfg.json
 
 RUN touch $ONOS/apps/org.onosproject.hostprovider/active