Reduce CCSDK docker images size
[ccsdk/distribution.git] / opendaylight / fluorine / fluorine-alpine / src / main / docker / Dockerfile
index a043e1e..b5e91b9 100644 (file)
@@ -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}