alshabib

revamped Dockerfile to produce a smaller image (half the previous size)

Change-Id: Ia8d7cfc3ecbe167addc7bf7102a254900fbe8c2c
1 FROM debian 1 FROM debian
2 MAINTAINER Ali Al-Shabibi <ali@onlab.us> 2 MAINTAINER Ali Al-Shabibi <ali@onlab.us>
3 3
4 -# Install required software 4 +# Add Java 8 repository
5 ENV DEBIAN_FRONTEND noninteractive 5 ENV DEBIAN_FRONTEND noninteractive
6 RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \ 6 RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
7 echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \ 7 echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \
8 echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \ 8 echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \
9 - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 && \ 9 + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
10 - apt-get update && \
11 - apt-get install -y oracle-java8-installer oracle-java8-set-default maven git curl && \
12 - apt-get clean && apt-get purge
13 10
14 # Set the environment variables 11 # Set the environment variables
15 ENV HOME /root 12 ENV HOME /root
...@@ -21,24 +18,28 @@ ENV KARAF_LOG /root/onos/apache-karaf-3.0.3/data/log/karaf.log ...@@ -21,24 +18,28 @@ ENV KARAF_LOG /root/onos/apache-karaf-3.0.3/data/log/karaf.log
21 ENV BUILD_NUMBER docker 18 ENV BUILD_NUMBER docker
22 ENV PATH $PATH:$KARAF_ROOT/bin 19 ENV PATH $PATH:$KARAF_ROOT/bin
23 20
24 - 21 +#Download and Build ONOS
25 -# Change to /src directory
26 WORKDIR /src 22 WORKDIR /src
27 - 23 +RUN apt-get update && apt-get install -y maven git curl oracle-java8-installer oracle-java8-set-default && \
28 -# Download ONOS 24 + git clone https://github.com/opennetworkinglab/onos.git && cd onos && \
29 -RUN git clone https://github.com/opennetworkinglab/onos.git 25 + mkdir -p /root/Downloads && \
30 -
31 -#Install ONOS
32 -WORKDIR /src/onos
33 -RUN mkdir -p /root/Downloads && \
34 mvn clean install && \ 26 mvn clean install && \
35 - ./tools/build/onos-package 27 + tools/build/onos-package && \
28 + rm -rf /root/.m2 && cd .. && \
29 + rm -rf onos && \
30 + apt-get remove --purge -y `apt-mark showauto` && \
31 + apt-get install oracle-java8-set-default -y && \
32 + apt-get clean && apt-get purge -y && apt-get autoremove -y && \
33 + rm -rf /var/lib/apt/lists/* && \
34 + rm -rf /var/cache/oracle-jdk8-installer && \
35 + rm -rf /root/Downloads
36 36
37 # Change to /root directory 37 # Change to /root directory
38 WORKDIR /root 38 WORKDIR /root
39 39
40 +#Install ONOS
40 RUN mkdir onos && \ 41 RUN mkdir onos && \
41 - cp /tmp/onos-*.docker.tar.gz . && \ 42 + mv /tmp/onos-*.docker.tar.gz . && \
42 tar -xf onos-*.docker.tar.gz -C onos --strip-components=1 && \ 43 tar -xf onos-*.docker.tar.gz -C onos --strip-components=1 && \
43 rm -rf onos-*.docker.tar.gz 44 rm -rf onos-*.docker.tar.gz
44 45
......