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