Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 1 | ARG JOBS=2 |
Jonathan Hart | bdf39a7 | 2020-02-25 13:53:23 -0800 | [diff] [blame] | 2 | ARG PROFILE=default |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 3 | ARG TAG=11.0.8-11.41.23 |
| 4 | ARG JAVA_PATH=/usr/lib/jvm/zulu11-ca-amd64 |
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. |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 8 | FROM azul/zulu-openjdk:${TAG} 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 | bae733a | 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 | |
Carmelo Cascone | 5c2807c | 2020-08-03 01:12:10 -0700 | [diff] [blame^] | 22 | # Install Bazelisk, which will download the version of bazel specified in |
| 23 | # .bazelversion |
| 24 | RUN curl -L -o bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.5.0/bazelisk-linux-amd64 |
| 25 | RUN chmod +x bazelisk && mv bazelisk /usr/bin |
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 |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 41 | ARG JAVA_PATH |
Jonathan Hart | bdf39a7 | 2020-02-25 13:53:23 -0800 | [diff] [blame] | 42 | ARG PROFILE |
Carmelo Cascone | 5c2807c | 2020-08-03 01:12:10 -0700 | [diff] [blame^] | 43 | RUN bazelisk 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 | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 48 | --define=ABSOLUTE_JAVABASE=${JAVA_PATH} \ |
Jonathan Hart | bdf39a7 | 2020-02-25 13:53:23 -0800 | [diff] [blame] | 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. |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 57 | FROM azul/zulu-openjdk:${TAG} |
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 | 91f3cb6 | 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) |
pierventre | 3883c60 | 2020-07-23 18:36:29 +0200 | [diff] [blame] | 75 | ARG JAVA_PATH |
| 76 | ENV JAVA_HOME ${JAVA_PATH} |
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"] |