blob: f4fb78443e81a9cb7a121571dafbc7e9304b0a22 [file] [log] [blame]
Carmelo Casconed33d3b42019-06-18 12:12:36 -07001ARG JOBS=2
Jonathan Hartbdf39a72020-02-25 13:53:23 -08002ARG PROFILE=default
pierventre3883c602020-07-23 18:36:29 +02003ARG TAG=11.0.8-11.41.23
4ARG JAVA_PATH=/usr/lib/jvm/zulu11-ca-amd64
alshabib187f1722015-06-23 16:15:50 -07005
Carmelo Casconed33d3b42019-06-18 12:12:36 -07006# First stage is the build environment.
Carmelo Casconee5b1d252019-06-26 15:56:51 -07007# zulu-openjdk images are based on Ubuntu.
pierventre3883c602020-07-23 18:36:29 +02008FROM azul/zulu-openjdk:${TAG} as builder
Carmelo Casconed33d3b42019-06-18 12:12:36 -07009
10ENV BUILD_DEPS \
11 ca-certificates \
12 zip \
13 python \
14 python3 \
15 git \
16 bzip2 \
17 build-essential \
18 curl \
Brian O'Connorbae733a2019-10-11 00:52:36 +000019 unzip
Carmelo Casconee5b1d252019-06-26 15:56:51 -070020RUN apt-get update && apt-get install -y ${BUILD_DEPS}
Carmelo Casconed33d3b42019-06-18 12:12:36 -070021
Carmelo Cascone5c2807c2020-08-03 01:12:10 -070022# Install Bazelisk, which will download the version of bazel specified in
23# .bazelversion
24RUN curl -L -o bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.5.0/bazelisk-linux-amd64
25RUN chmod +x bazelisk && mv bazelisk /usr/bin
Carmelo Casconed33d3b42019-06-18 12:12:36 -070026
27# Build-stage environment variables
Carmelo Casconee5b1d252019-06-26 15:56:51 -070028ENV ONOS_ROOT /src/onos
alshabib187f1722015-06-23 16:15:50 -070029ENV BUILD_NUMBER docker
Ray Milkey8c05c9b2017-03-15 15:47:57 -070030ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
Jonathan Hart809edee2016-12-15 18:33:05 -080031
Carmelo Casconed33d3b42019-06-18 12:12:36 -070032# Copy in the sources
33COPY . ${ONOS_ROOT}
34WORKDIR ${ONOS_ROOT}
Jonathan Hart15a71d82017-07-20 16:14:21 -070035
Carmelo Casconee5b1d252019-06-26 15:56:51 -070036# 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 Casconed33d3b42019-06-18 12:12:36 -070040ARG JOBS
pierventre3883c602020-07-23 18:36:29 +020041ARG JAVA_PATH
Jonathan Hartbdf39a72020-02-25 13:53:23 -080042ARG PROFILE
Carmelo Cascone5c2807c2020-08-03 01:12:10 -070043RUN bazelisk build onos \
Carmelo Casconed33d3b42019-06-18 12:12:36 -070044 --jobs ${JOBS} \
Carmelo Casconee5b1d252019-06-26 15:56:51 -070045 --verbose_failures \
46 --javabase=@bazel_tools//tools/jdk:absolute_javabase \
47 --host_javabase=@bazel_tools//tools/jdk:absolute_javabase \
pierventre3883c602020-07-23 18:36:29 +020048 --define=ABSOLUTE_JAVABASE=${JAVA_PATH} \
Jonathan Hartbdf39a72020-02-25 13:53:23 -080049 --define profile=${PROFILE}
Carmelo Casconed33d3b42019-06-18 12:12:36 -070050
Carmelo Casconee5b1d252019-06-26 15:56:51 -070051# 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.
53RUN mkdir /output
54RUN tar -xf bazel-bin/onos.tar.gz -C /output --strip-components=1
Carmelo Casconed33d3b42019-06-18 12:12:36 -070055
Carmelo Casconee5b1d252019-06-26 15:56:51 -070056# Second and final stage is the runtime environment.
pierventre3883c602020-07-23 18:36:29 +020057FROM azul/zulu-openjdk:${TAG}
Jonathan Hart3e864192017-07-20 19:24:49 -070058
Jonathan Hart15a71d82017-07-20 16:14:21 -070059LABEL 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 Casconee5b1d252019-06-26 15:56:51 -070064 org.label-schema.schema-version="1.0" \
65 maintainer="onos-dev@onosproject.org"
66
Jonathan Hart91f3cb62019-12-02 13:19:35 -080067RUN apt-get update && apt-get install -y curl && \
68 rm -rf /var/lib/apt/lists/*
69
Carmelo Casconee5b1d252019-06-26 15:56:51 -070070# Install ONOS in /root/onos
71COPY --from=builder /output/ /root/onos/
72WORKDIR /root/onos
73
74# Set JAVA_HOME (by default not exported by zulu images)
pierventre3883c602020-07-23 18:36:29 +020075ARG JAVA_PATH
76ENV JAVA_HOME ${JAVA_PATH}
alshabib187f1722015-06-23 16:15:50 -070077
78# Ports
Charles Chan45624b82015-08-24 00:29:20 +080079# 6653 - OpenFlow
Jonathan Hart77daee82017-01-16 14:29:20 -080080# 6640 - OVSDB
alshabib187f1722015-06-23 16:15:50 -070081# 8181 - GUI
82# 8101 - ONOS CLI
Jonathan Hart15a71d82017-07-20 16:14:21 -070083# 9876 - ONOS intra-cluster communication
Jonathan Hart77daee82017-01-16 14:29:20 -080084EXPOSE 6653 6640 8181 8101 9876
alshabib187f1722015-06-23 16:15:50 -070085
Carmelo Casconee5b1d252019-06-26 15:56:51 -070086# Run ONOS
David Bainbridgeff4fb042015-08-17 12:53:29 -070087ENTRYPOINT ["./bin/onos-service"]
Jonathan Hart3e864192017-07-20 19:24:49 -070088CMD ["server"]