Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 1 | # First stage is the build environment |
| 2 | FROM sgrio/java-oracle:jdk_8 as builder |
| 3 | MAINTAINER Jonathan Hart <jono@opennetworking.org> |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 4 | |
| 5 | # Set the environment variables |
| 6 | ENV HOME /root |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 7 | ENV BUILD_NUMBER docker |
Ray Milkey | 8c05c9b | 2017-03-15 15:47:57 -0700 | [diff] [blame] | 8 | ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 |
Jonathan Hart | 809edee | 2016-12-15 18:33:05 -0800 | [diff] [blame] | 9 | |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 10 | # Copy in the source |
Jonathan Hart | 587dfac | 2017-01-09 14:42:50 -0800 | [diff] [blame] | 11 | COPY . /src/onos/ |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 12 | |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 13 | # Build ONOS |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 14 | # We extract the tar in the build environment to avoid having to put the tar |
| 15 | # in the runtime environment - this saves a lot of space |
Ray Milkey | 9d81ea5 | 2017-07-20 10:36:51 -0700 | [diff] [blame] | 16 | # FIXME - dependence on ONOS_ROOT and git at build time is a hack to work around |
| 17 | # build problems |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 18 | WORKDIR /src/onos |
Ray Milkey | b38701e | 2018-08-14 08:43:36 -0700 | [diff] [blame] | 19 | RUN apt-get update && apt-get install -y zip python git bzip2 build-essential && \ |
Ray Milkey | 716166f | 2018-11-09 10:18:54 -0800 | [diff] [blame] | 20 | curl -L -o bazel.sh https://github.com/bazelbuild/bazel/releases/download/0.19.0/bazel-0.19.0-installer-linux-x86_64.sh && \ |
Ray Milkey | b38701e | 2018-08-14 08:43:36 -0700 | [diff] [blame] | 21 | chmod +x bazel.sh && \ |
| 22 | ./bazel.sh --user && \ |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 23 | export ONOS_ROOT=/src/onos && \ |
Ray Milkey | b38701e | 2018-08-14 08:43:36 -0700 | [diff] [blame] | 24 | ln -s /usr/lib/jvm/java-8-oracle/bin/jar /etc/alternatives/jar && \ |
| 25 | ln -s /etc/alternatives/jar /usr/bin/jar && \ |
Ray Milkey | b42f4dd | 2018-08-14 10:24:26 -0700 | [diff] [blame] | 26 | ~/bin/bazel build onos --verbose_failures --jobs 2 && \ |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 27 | mkdir -p /src/tar && \ |
| 28 | cd /src/tar && \ |
Ray Milkey | b38701e | 2018-08-14 08:43:36 -0700 | [diff] [blame] | 29 | tar -xf /src/onos/bazel-bin/onos.tar.gz --strip-components=1 && \ |
| 30 | rm -rf /src/onos/bazel-* .git |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 31 | |
| 32 | # Second stage is the runtime environment |
Ray Milkey | 6f5b646 | 2018-12-12 15:31:30 -0800 | [diff] [blame] | 33 | FROM adoptopenjdk/openjdk11:x86_64-ubuntu-jdk-11.0.1.13-slim |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 34 | |
| 35 | # Change to /root directory |
Ray Milkey | 6f5b646 | 2018-12-12 15:31:30 -0800 | [diff] [blame] | 36 | RUN mkdir -p /root/onos |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 37 | WORKDIR /root/onos |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 38 | |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 39 | # Install ONOS |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 40 | COPY --from=builder /src/tar/ . |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 41 | |
Jonathan Hart | 3e86419 | 2017-07-20 19:24:49 -0700 | [diff] [blame] | 42 | # Configure ONOS to log to stdout |
| 43 | RUN sed -ibak '/log4j.rootLogger=/s/$/, stdout/' $(ls -d apache-karaf-*)/etc/org.ops4j.pax.logging.cfg |
| 44 | |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 45 | LABEL org.label-schema.name="ONOS" \ |
| 46 | org.label-schema.description="SDN Controller" \ |
| 47 | org.label-schema.usage="http://wiki.onosproject.org" \ |
| 48 | org.label-schema.url="http://onosproject.org" \ |
| 49 | org.label-scheme.vendor="Open Networking Foundation" \ |
| 50 | org.label-schema.schema-version="1.0" |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 51 | |
| 52 | # Ports |
Charles Chan | 45624b8 | 2015-08-24 00:29:20 +0800 | [diff] [blame] | 53 | # 6653 - OpenFlow |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 54 | # 6640 - OVSDB |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 55 | # 8181 - GUI |
| 56 | # 8101 - ONOS CLI |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 57 | # 9876 - ONOS intra-cluster communication |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 58 | EXPOSE 6653 6640 8181 8101 9876 |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 59 | |
| 60 | # Get ready to run command |
David Bainbridge | ff4fb04 | 2015-08-17 12:53:29 -0700 | [diff] [blame] | 61 | ENTRYPOINT ["./bin/onos-service"] |
Jonathan Hart | 3e86419 | 2017-07-20 19:24:49 -0700 | [diff] [blame] | 62 | CMD ["server"] |