blob: eb6e10474ce1bd2d15e4bb41e3e160d6298474a4 [file] [log] [blame]
Jonathan Hart15a71d82017-07-20 16:14:21 -07001# First stage is the build environment
2FROM sgrio/java-oracle:jdk_8 as builder
3MAINTAINER Jonathan Hart <jono@opennetworking.org>
alshabib187f1722015-06-23 16:15:50 -07004
5# Set the environment variables
6ENV HOME /root
alshabib187f1722015-06-23 16:15:50 -07007ENV BUILD_NUMBER docker
Ray Milkey8c05c9b2017-03-15 15:47:57 -07008ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
Jonathan Hart809edee2016-12-15 18:33:05 -08009
Jonathan Hart77daee82017-01-16 14:29:20 -080010# Copy in the source
Jonathan Hart587dfac2017-01-09 14:42:50 -080011COPY . /src/onos/
alshabib187f1722015-06-23 16:15:50 -070012
Jonathan Hart77daee82017-01-16 14:29:20 -080013# Build ONOS
Jonathan Hart15a71d82017-07-20 16:14:21 -070014# We extract the tar in the build environment to avoid having to put the tar
15# in the runtime environment - this saves a lot of space
Ray Milkey9d81ea52017-07-20 10:36:51 -070016# FIXME - dependence on ONOS_ROOT and git at build time is a hack to work around
17# build problems
Jonathan Hart15a71d82017-07-20 16:14:21 -070018WORKDIR /src/onos
Ray Milkeyb38701e2018-08-14 08:43:36 -070019RUN apt-get update && apt-get install -y zip python git bzip2 build-essential && \
Ray Milkey716166f2018-11-09 10:18:54 -080020 curl -L -o bazel.sh https://github.com/bazelbuild/bazel/releases/download/0.19.0/bazel-0.19.0-installer-linux-x86_64.sh && \
Ray Milkeyb38701e2018-08-14 08:43:36 -070021 chmod +x bazel.sh && \
22 ./bazel.sh --user && \
Jonathan Hart15a71d82017-07-20 16:14:21 -070023 export ONOS_ROOT=/src/onos && \
Ray Milkeyb38701e2018-08-14 08:43:36 -070024 ln -s /usr/lib/jvm/java-8-oracle/bin/jar /etc/alternatives/jar && \
25 ln -s /etc/alternatives/jar /usr/bin/jar && \
Ray Milkeyb42f4dd2018-08-14 10:24:26 -070026 ~/bin/bazel build onos --verbose_failures --jobs 2 && \
Jonathan Hart15a71d82017-07-20 16:14:21 -070027 mkdir -p /src/tar && \
28 cd /src/tar && \
Ray Milkeyb38701e2018-08-14 08:43:36 -070029 tar -xf /src/onos/bazel-bin/onos.tar.gz --strip-components=1 && \
30 rm -rf /src/onos/bazel-* .git
Jonathan Hart15a71d82017-07-20 16:14:21 -070031
32# Second stage is the runtime environment
Ray Milkey6f5b6462018-12-12 15:31:30 -080033FROM adoptopenjdk/openjdk11:x86_64-ubuntu-jdk-11.0.1.13-slim
alshabib187f1722015-06-23 16:15:50 -070034
35# Change to /root directory
Ray Milkey6f5b6462018-12-12 15:31:30 -080036RUN mkdir -p /root/onos
Jonathan Hart15a71d82017-07-20 16:14:21 -070037WORKDIR /root/onos
alshabib187f1722015-06-23 16:15:50 -070038
Jonathan Hart77daee82017-01-16 14:29:20 -080039# Install ONOS
Jonathan Hart15a71d82017-07-20 16:14:21 -070040COPY --from=builder /src/tar/ .
alshabib187f1722015-06-23 16:15:50 -070041
Jonathan Hart3e864192017-07-20 19:24:49 -070042# Configure ONOS to log to stdout
43RUN sed -ibak '/log4j.rootLogger=/s/$/, stdout/' $(ls -d apache-karaf-*)/etc/org.ops4j.pax.logging.cfg
44
Jonathan Hart15a71d82017-07-20 16:14:21 -070045LABEL org.label-schema.name="ONOS" \
46 org.label-schema.description="SDN Controller" \
47 org.label-schema.usage="http://wiki.onosproject.org" \
48 org.label-schema.url="http://onosproject.org" \
49 org.label-scheme.vendor="Open Networking Foundation" \
50 org.label-schema.schema-version="1.0"
alshabib187f1722015-06-23 16:15:50 -070051
52# Ports
Charles Chan45624b82015-08-24 00:29:20 +080053# 6653 - OpenFlow
Jonathan Hart77daee82017-01-16 14:29:20 -080054# 6640 - OVSDB
alshabib187f1722015-06-23 16:15:50 -070055# 8181 - GUI
56# 8101 - ONOS CLI
Jonathan Hart15a71d82017-07-20 16:14:21 -070057# 9876 - ONOS intra-cluster communication
Jonathan Hart77daee82017-01-16 14:29:20 -080058EXPOSE 6653 6640 8181 8101 9876
alshabib187f1722015-06-23 16:15:50 -070059
60# Get ready to run command
David Bainbridgeff4fb042015-08-17 12:53:29 -070061ENTRYPOINT ["./bin/onos-service"]
Jonathan Hart3e864192017-07-20 19:24:49 -070062CMD ["server"]