pierventre | 5489c2f | 2022-05-06 19:01:27 +0200 | [diff] [blame] | 1 | # Copyright 2015-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | # With this dockerfile you can build a ONOS Docker container |
| 16 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 17 | ARG JOBS=2 |
Jonathan Hart | bdf39a7 | 2020-02-25 13:53:23 -0800 | [diff] [blame] | 18 | ARG PROFILE=default |
pierventre | 69db90c | 2022-05-06 23:06:20 +0200 | [diff] [blame] | 19 | ARG TAG=11.0.13-11.52.13 |
| 20 | ARG JAVA_PATH=/usr/lib/jvm/zulu11 |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 21 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 22 | # First stage is the build environment. |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 23 | # zulu-openjdk images are based on Ubuntu. |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 24 | FROM azul/zulu-openjdk:${TAG} as builder |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 25 | |
| 26 | ENV BUILD_DEPS \ |
| 27 | ca-certificates \ |
| 28 | zip \ |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 29 | python3 \ |
| 30 | git \ |
| 31 | bzip2 \ |
| 32 | build-essential \ |
| 33 | curl \ |
Brian O'Connor | bae733a | 2019-10-11 00:52:36 +0000 | [diff] [blame] | 34 | unzip |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 35 | RUN apt-get update && apt-get install -y ${BUILD_DEPS} |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 36 | |
Carmelo Cascone | 5c2807c | 2020-08-03 01:12:10 -0700 | [diff] [blame] | 37 | # Install Bazelisk, which will download the version of bazel specified in |
| 38 | # .bazelversion |
pierventre | 5489c2f | 2022-05-06 19:01:27 +0200 | [diff] [blame] | 39 | RUN curl -L -o bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.11.0/bazelisk-linux-amd64 |
Carmelo Cascone | 5c2807c | 2020-08-03 01:12:10 -0700 | [diff] [blame] | 40 | RUN chmod +x bazelisk && mv bazelisk /usr/bin |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 41 | |
| 42 | # Build-stage environment variables |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 43 | ENV ONOS_ROOT /src/onos |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 44 | ENV BUILD_NUMBER docker |
Ray Milkey | 8c05c9b | 2017-03-15 15:47:57 -0700 | [diff] [blame] | 45 | ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 |
Jonathan Hart | 809edee | 2016-12-15 18:33:05 -0800 | [diff] [blame] | 46 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 47 | # Copy in the sources |
| 48 | COPY . ${ONOS_ROOT} |
| 49 | WORKDIR ${ONOS_ROOT} |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 50 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 51 | # Build ONOS using the JDK pre-installed in the base image, instead of the |
| 52 | # Bazel-provided remote one. By doing wo we make sure to build with the most |
| 53 | # updated JDK, including bug and security fixes, independently of the Bazel |
pierventre | 5489c2f | 2022-05-06 19:01:27 +0200 | [diff] [blame] | 54 | # version. NOTE that WORKSPACE-docker file defines dockerjdk |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 55 | ARG JOBS |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 56 | ARG JAVA_PATH |
Jonathan Hart | bdf39a7 | 2020-02-25 13:53:23 -0800 | [diff] [blame] | 57 | ARG PROFILE |
pierventre | 5489c2f | 2022-05-06 19:01:27 +0200 | [diff] [blame] | 58 | RUN cat WORKSPACE-docker >> WORKSPACE && bazelisk build onos \ |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 59 | --jobs ${JOBS} \ |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 60 | --verbose_failures \ |
pierventre | 5489c2f | 2022-05-06 19:01:27 +0200 | [diff] [blame] | 61 | --java_runtime_version=dockerjdk_11 \ |
| 62 | --tool_java_runtime_version=dockerjdk_11 \ |
Jonathan Hart | bdf39a7 | 2020-02-25 13:53:23 -0800 | [diff] [blame] | 63 | --define profile=${PROFILE} |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 64 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 65 | # We extract the tar in the build environment to avoid having to put the tar in |
| 66 | # the runtime stage. This saves a lot of space. |
| 67 | RUN mkdir /output |
| 68 | 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] | 69 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 70 | # Second and final stage is the runtime environment. |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 71 | FROM azul/zulu-openjdk:${TAG} |
Jonathan Hart | 3e86419 | 2017-07-20 19:24:49 -0700 | [diff] [blame] | 72 | |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 73 | LABEL org.label-schema.name="ONOS" \ |
| 74 | org.label-schema.description="SDN Controller" \ |
| 75 | org.label-schema.usage="http://wiki.onosproject.org" \ |
| 76 | org.label-schema.url="http://onosproject.org" \ |
| 77 | org.label-scheme.vendor="Open Networking Foundation" \ |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 78 | org.label-schema.schema-version="1.0" \ |
| 79 | maintainer="onos-dev@onosproject.org" |
| 80 | |
Jonathan Hart | 91f3cb6 | 2019-12-02 13:19:35 -0800 | [diff] [blame] | 81 | RUN apt-get update && apt-get install -y curl && \ |
| 82 | rm -rf /var/lib/apt/lists/* |
| 83 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 84 | # Install ONOS in /root/onos |
| 85 | COPY --from=builder /output/ /root/onos/ |
| 86 | WORKDIR /root/onos |
| 87 | |
| 88 | # Set JAVA_HOME (by default not exported by zulu images) |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 89 | ARG JAVA_PATH |
| 90 | ENV JAVA_HOME ${JAVA_PATH} |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 91 | |
| 92 | # Ports |
Charles Chan | 45624b8 | 2015-08-24 00:29:20 +0800 | [diff] [blame] | 93 | # 6653 - OpenFlow |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 94 | # 6640 - OVSDB |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 95 | # 8181 - GUI |
| 96 | # 8101 - ONOS CLI |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 97 | # 9876 - ONOS intra-cluster communication |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 98 | EXPOSE 6653 6640 8181 8101 9876 |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 99 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 100 | # Run ONOS |
David Bainbridge | ff4fb04 | 2015-08-17 12:53:29 -0700 | [diff] [blame] | 101 | ENTRYPOINT ["./bin/onos-service"] |
Jonathan Hart | 3e86419 | 2017-07-20 19:24:49 -0700 | [diff] [blame] | 102 | CMD ["server"] |