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