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} |
Davide Scano | 51886ce | 2024-04-12 22:35:18 +0200 | [diff] [blame] | 36 | ENV BAZELISK_BASE_URL="https://releases.bazel.build/6.0.0/rolling" |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 37 | |
Carmelo Cascone | 5c2807c | 2020-08-03 01:12:10 -0700 | [diff] [blame] | 38 | # Install Bazelisk, which will download the version of bazel specified in |
| 39 | # .bazelversion |
Davide Scano | 51886ce | 2024-04-12 22:35:18 +0200 | [diff] [blame] | 40 | RUN curl -L -o bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64 |
Carmelo Cascone | 5c2807c | 2020-08-03 01:12:10 -0700 | [diff] [blame] | 41 | RUN chmod +x bazelisk && mv bazelisk /usr/bin |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 42 | |
| 43 | # Build-stage environment variables |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 44 | ENV ONOS_ROOT /src/onos |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 45 | ENV BUILD_NUMBER docker |
Ray Milkey | 8c05c9b | 2017-03-15 15:47:57 -0700 | [diff] [blame] | 46 | ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 |
Jonathan Hart | 809edee | 2016-12-15 18:33:05 -0800 | [diff] [blame] | 47 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 48 | # Copy in the sources |
| 49 | COPY . ${ONOS_ROOT} |
| 50 | WORKDIR ${ONOS_ROOT} |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 51 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 52 | # Build ONOS using the JDK pre-installed in the base image, instead of the |
| 53 | # Bazel-provided remote one. By doing wo we make sure to build with the most |
| 54 | # updated JDK, including bug and security fixes, independently of the Bazel |
pierventre | 5489c2f | 2022-05-06 19:01:27 +0200 | [diff] [blame] | 55 | # version. NOTE that WORKSPACE-docker file defines dockerjdk |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 56 | ARG JOBS |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 57 | ARG JAVA_PATH |
Jonathan Hart | bdf39a7 | 2020-02-25 13:53:23 -0800 | [diff] [blame] | 58 | ARG PROFILE |
pierventre | 5489c2f | 2022-05-06 19:01:27 +0200 | [diff] [blame] | 59 | RUN cat WORKSPACE-docker >> WORKSPACE && bazelisk build onos \ |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 60 | --jobs ${JOBS} \ |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 61 | --verbose_failures \ |
pierventre | 5489c2f | 2022-05-06 19:01:27 +0200 | [diff] [blame] | 62 | --java_runtime_version=dockerjdk_11 \ |
| 63 | --tool_java_runtime_version=dockerjdk_11 \ |
Jonathan Hart | bdf39a7 | 2020-02-25 13:53:23 -0800 | [diff] [blame] | 64 | --define profile=${PROFILE} |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 65 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 66 | # We extract the tar in the build environment to avoid having to put the tar in |
| 67 | # the runtime stage. This saves a lot of space. |
| 68 | RUN mkdir /output |
| 69 | 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] | 70 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 71 | # Second and final stage is the runtime environment. |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 72 | FROM azul/zulu-openjdk:${TAG} |
Jonathan Hart | 3e86419 | 2017-07-20 19:24:49 -0700 | [diff] [blame] | 73 | |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 74 | LABEL org.label-schema.name="ONOS" \ |
| 75 | org.label-schema.description="SDN Controller" \ |
| 76 | org.label-schema.usage="http://wiki.onosproject.org" \ |
| 77 | org.label-schema.url="http://onosproject.org" \ |
| 78 | org.label-scheme.vendor="Open Networking Foundation" \ |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 79 | org.label-schema.schema-version="1.0" \ |
| 80 | maintainer="onos-dev@onosproject.org" |
| 81 | |
Jonathan Hart | 91f3cb6 | 2019-12-02 13:19:35 -0800 | [diff] [blame] | 82 | RUN apt-get update && apt-get install -y curl && \ |
| 83 | rm -rf /var/lib/apt/lists/* |
| 84 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 85 | # Install ONOS in /root/onos |
| 86 | COPY --from=builder /output/ /root/onos/ |
| 87 | WORKDIR /root/onos |
| 88 | |
| 89 | # Set JAVA_HOME (by default not exported by zulu images) |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 90 | ARG JAVA_PATH |
| 91 | ENV JAVA_HOME ${JAVA_PATH} |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 92 | |
| 93 | # Ports |
Charles Chan | 45624b8 | 2015-08-24 00:29:20 +0800 | [diff] [blame] | 94 | # 6653 - OpenFlow |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 95 | # 6640 - OVSDB |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 96 | # 8181 - GUI |
| 97 | # 8101 - ONOS CLI |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 98 | # 9876 - ONOS intra-cluster communication |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 99 | EXPOSE 6653 6640 8181 8101 9876 |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 100 | |
Carmelo Cascone | e5b1d25 | 2019-06-26 15:56:51 -0700 | [diff] [blame] | 101 | # Run ONOS |
David Bainbridge | ff4fb04 | 2015-08-17 12:53:29 -0700 | [diff] [blame] | 102 | ENTRYPOINT ["./bin/onos-service"] |
Davide Scano | 51886ce | 2024-04-12 22:35:18 +0200 | [diff] [blame] | 103 | CMD ["server"] |