Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 1 | ARG JDK_VER=11 |
Carmelo Cascone | 212dc2f | 2019-11-21 22:13:09 -0800 | [diff] [blame] | 2 | ARG BAZEL_VER=1.0.0 |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 3 | ARG JOBS=2 |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 4 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 5 | # First stage is the build environment. |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 6 | # zulu-openjdk images are based on Ubuntu. |
| 7 | FROM azul/zulu-openjdk:${JDK_VER} as builder |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 8 | |
| 9 | ENV BUILD_DEPS \ |
| 10 | ca-certificates \ |
| 11 | zip \ |
| 12 | python \ |
| 13 | python3 \ |
| 14 | git \ |
| 15 | bzip2 \ |
| 16 | build-essential \ |
| 17 | curl \ |
Brian O'Connor | c7e0454 | 2019-10-11 00:52:36 +0000 | [diff] [blame] | 18 | unzip |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 19 | RUN apt-get update && apt-get install -y ${BUILD_DEPS} |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 20 | |
| 21 | # Install Bazel |
| 22 | ARG BAZEL_VER |
| 23 | RUN curl -L -o bazel.sh https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/bazel-${BAZEL_VER}-installer-linux-x86_64.sh |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 24 | RUN chmod +x bazel.sh && ./bazel.sh |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 25 | |
| 26 | # Build-stage environment variables |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 27 | ENV ONOS_ROOT /src/onos |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 28 | ENV BUILD_NUMBER docker |
Ray Milkey | 8c05c9b | 2017-03-15 15:47:57 -0700 | [diff] [blame] | 29 | ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 |
Jonathan Hart | 809edee | 2016-12-15 18:33:05 -0800 | [diff] [blame] | 30 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 31 | # Copy in the sources |
| 32 | COPY . ${ONOS_ROOT} |
| 33 | WORKDIR ${ONOS_ROOT} |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 34 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 35 | # Build ONOS using the JDK pre-installed in the base image, instead of the |
| 36 | # Bazel-provided remote one. By doing wo we make sure to build with the most |
| 37 | # updated JDK, including bug and security fixes, independently of the Bazel |
| 38 | # version. |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 39 | ARG JOBS |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 40 | ARG JDK_VER |
| 41 | RUN bazel build onos \ |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 42 | --jobs ${JOBS} \ |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 43 | --verbose_failures \ |
| 44 | --javabase=@bazel_tools//tools/jdk:absolute_javabase \ |
| 45 | --host_javabase=@bazel_tools//tools/jdk:absolute_javabase \ |
| 46 | --define=ABSOLUTE_JAVABASE=/usr/lib/jvm/zulu-${JDK_VER}-amd64 |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 47 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 48 | # We extract the tar in the build environment to avoid having to put the tar in |
| 49 | # the runtime stage. This saves a lot of space. |
| 50 | RUN mkdir /output |
| 51 | RUN tar -xf bazel-bin/onos.tar.gz -C /output --strip-components=1 |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 52 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 53 | # Second and final stage is the runtime environment. |
| 54 | FROM azul/zulu-openjdk:${JDK_VER} |
Jonathan Hart | 3e86419 | 2017-07-20 19:24:49 -0700 | [diff] [blame] | 55 | |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 56 | LABEL org.label-schema.name="ONOS" \ |
| 57 | org.label-schema.description="SDN Controller" \ |
| 58 | org.label-schema.usage="http://wiki.onosproject.org" \ |
| 59 | org.label-schema.url="http://onosproject.org" \ |
| 60 | org.label-scheme.vendor="Open Networking Foundation" \ |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 61 | org.label-schema.schema-version="1.0" \ |
| 62 | maintainer="onos-dev@onosproject.org" |
| 63 | |
| 64 | # Install ONOS in /root/onos |
| 65 | COPY --from=builder /output/ /root/onos/ |
| 66 | WORKDIR /root/onos |
| 67 | |
| 68 | # Set JAVA_HOME (by default not exported by zulu images) |
| 69 | ARG JDK_VER |
| 70 | ENV JAVA_HOME /usr/lib/jvm/zulu-${JDK_VER}-amd64 |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 71 | |
| 72 | # Ports |
Charles Chan | 45624b8 | 2015-08-24 00:29:20 +0800 | [diff] [blame] | 73 | # 6653 - OpenFlow |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 74 | # 6640 - OVSDB |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 75 | # 8181 - GUI |
| 76 | # 8101 - ONOS CLI |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 77 | # 9876 - ONOS intra-cluster communication |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 78 | EXPOSE 6653 6640 8181 8101 9876 |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 79 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 80 | # Run ONOS |
David Bainbridge | ff4fb04 | 2015-08-17 12:53:29 -0700 | [diff] [blame] | 81 | ENTRYPOINT ["./bin/onos-service"] |
Jonathan Hart | 3e86419 | 2017-07-20 19:24:49 -0700 | [diff] [blame] | 82 | CMD ["server"] |