Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 1 | ARG JDK_VER=11 |
| 2 | ARG BAZEL_VER=0.27.0 |
| 3 | ARG JOBS=2 |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 4 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 5 | # First stage is the build environment. |
| 6 | FROM ubuntu:18.04 as builder |
| 7 | |
| 8 | ENV BUILD_DEPS \ |
| 9 | ca-certificates \ |
| 10 | zip \ |
| 11 | python \ |
| 12 | python3 \ |
| 13 | git \ |
| 14 | bzip2 \ |
| 15 | build-essential \ |
| 16 | curl \ |
| 17 | unzip |
| 18 | RUN apt-get update |
| 19 | RUN apt-get install -y ${BUILD_DEPS} |
| 20 | |
| 21 | # Install Bazel |
| 22 | ARG BAZEL_VER |
| 23 | RUN curl -L -o bazel.sh https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/bazel-${BAZEL_VER}-installer-linux-x86_64.sh |
| 24 | RUN chmod +x bazel.sh && ./bazel.sh --user |
| 25 | |
| 26 | # Build-stage environment variables |
| 27 | ENV ONOS_ROOT=/src/onos |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 28 | ENV BUILD_NUMBER docker |
Ray Milkey | 8c05c9b | 2017-03-15 15:47:57 -0700 | [diff] [blame] | 29 | ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 |
Jonathan Hart | 809edee | 2016-12-15 18:33:05 -0800 | [diff] [blame] | 30 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 31 | # Build ONOS. We extract the tar in the build environment to avoid having to put |
| 32 | # the tar in the runtime stage. This saves a lot of space. |
| 33 | # Note: we don't install a JDK but instead we rely on that provided by Bazel. |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 34 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 35 | # Copy in the sources |
| 36 | COPY . ${ONOS_ROOT} |
| 37 | WORKDIR ${ONOS_ROOT} |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 38 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 39 | ARG JOBS |
| 40 | ENV BAZEL_BUILD_ARGS \ |
| 41 | --jobs ${JOBS} \ |
| 42 | --verbose_failures |
| 43 | RUN ~/bin/bazel build onos ${BAZEL_BUILD_ARGS} |
| 44 | |
| 45 | RUN mkdir /src/tar |
| 46 | RUN tar -xf bazel-bin/onos.tar.gz -C /src/tar --strip-components=1 |
| 47 | |
| 48 | # Second stage is the runtime environment. |
| 49 | # We use Amazon Corretto official Docker image, bazed on Amazon Linux 2 (rhel/fedora like) |
| 50 | FROM amazoncorretto:${JDK_VER} |
| 51 | |
| 52 | MAINTAINER Ray Milkey <ray@opennetworking.org> |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 53 | |
| 54 | # Change to /root directory |
Ray Milkey | 6f5b646 | 2018-12-12 15:31:30 -0800 | [diff] [blame] | 55 | RUN mkdir -p /root/onos |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 56 | WORKDIR /root/onos |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 57 | |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 58 | # Install ONOS |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 59 | COPY --from=builder /src/tar/ . |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 60 | |
Jonathan Hart | 3e86419 | 2017-07-20 19:24:49 -0700 | [diff] [blame] | 61 | # Configure ONOS to log to stdout |
| 62 | RUN sed -ibak '/log4j.rootLogger=/s/$/, stdout/' $(ls -d apache-karaf-*)/etc/org.ops4j.pax.logging.cfg |
| 63 | |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 64 | LABEL org.label-schema.name="ONOS" \ |
| 65 | org.label-schema.description="SDN Controller" \ |
| 66 | org.label-schema.usage="http://wiki.onosproject.org" \ |
| 67 | org.label-schema.url="http://onosproject.org" \ |
| 68 | org.label-scheme.vendor="Open Networking Foundation" \ |
| 69 | org.label-schema.schema-version="1.0" |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 70 | |
| 71 | # Ports |
Charles Chan | 45624b8 | 2015-08-24 00:29:20 +0800 | [diff] [blame] | 72 | # 6653 - OpenFlow |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 73 | # 6640 - OVSDB |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 74 | # 8181 - GUI |
| 75 | # 8101 - ONOS CLI |
Jonathan Hart | 15a71d8 | 2017-07-20 16:14:21 -0700 | [diff] [blame] | 76 | # 9876 - ONOS intra-cluster communication |
Jonathan Hart | 77daee8 | 2017-01-16 14:29:20 -0800 | [diff] [blame] | 77 | EXPOSE 6653 6640 8181 8101 9876 |
alshabib | 187f172 | 2015-06-23 16:15:50 -0700 | [diff] [blame] | 78 | |
| 79 | # Get ready to run command |
David Bainbridge | ff4fb04 | 2015-08-17 12:53:29 -0700 | [diff] [blame] | 80 | ENTRYPOINT ["./bin/onos-service"] |
Jonathan Hart | 3e86419 | 2017-07-20 19:24:49 -0700 | [diff] [blame] | 81 | CMD ["server"] |