blob: 517323e994258be33bb5f4ad181215d34389b279 [file] [log] [blame]
Carmelo Casconed33d3b42019-06-18 12:12:36 -07001ARG JDK_VER=11
2ARG BAZEL_VER=0.27.0
3ARG JOBS=2
alshabib187f1722015-06-23 16:15:50 -07004
Carmelo Casconed33d3b42019-06-18 12:12:36 -07005# First stage is the build environment.
6FROM ubuntu:18.04 as builder
7
8ENV BUILD_DEPS \
9 ca-certificates \
10 zip \
11 python \
12 python3 \
13 git \
14 bzip2 \
15 build-essential \
16 curl \
17 unzip
18RUN apt-get update
19RUN apt-get install -y ${BUILD_DEPS}
20
21# Install Bazel
22ARG BAZEL_VER
23RUN curl -L -o bazel.sh https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/bazel-${BAZEL_VER}-installer-linux-x86_64.sh
24RUN chmod +x bazel.sh && ./bazel.sh --user
25
26# Build-stage environment variables
27ENV ONOS_ROOT=/src/onos
alshabib187f1722015-06-23 16:15:50 -070028ENV BUILD_NUMBER docker
Ray Milkey8c05c9b2017-03-15 15:47:57 -070029ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
Jonathan Hart809edee2016-12-15 18:33:05 -080030
Carmelo Casconed33d3b42019-06-18 12:12:36 -070031# 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.
alshabib187f1722015-06-23 16:15:50 -070034
Carmelo Casconed33d3b42019-06-18 12:12:36 -070035# Copy in the sources
36COPY . ${ONOS_ROOT}
37WORKDIR ${ONOS_ROOT}
Jonathan Hart15a71d82017-07-20 16:14:21 -070038
Carmelo Casconed33d3b42019-06-18 12:12:36 -070039ARG JOBS
40ENV BAZEL_BUILD_ARGS \
41 --jobs ${JOBS} \
42 --verbose_failures
43RUN ~/bin/bazel build onos ${BAZEL_BUILD_ARGS}
44
45RUN mkdir /src/tar
46RUN 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)
50FROM amazoncorretto:${JDK_VER}
51
52MAINTAINER Ray Milkey <ray@opennetworking.org>
alshabib187f1722015-06-23 16:15:50 -070053
54# Change to /root directory
Ray Milkey6f5b6462018-12-12 15:31:30 -080055RUN mkdir -p /root/onos
Jonathan Hart15a71d82017-07-20 16:14:21 -070056WORKDIR /root/onos
alshabib187f1722015-06-23 16:15:50 -070057
Jonathan Hart77daee82017-01-16 14:29:20 -080058# Install ONOS
Jonathan Hart15a71d82017-07-20 16:14:21 -070059COPY --from=builder /src/tar/ .
alshabib187f1722015-06-23 16:15:50 -070060
Jonathan Hart3e864192017-07-20 19:24:49 -070061# Configure ONOS to log to stdout
62RUN sed -ibak '/log4j.rootLogger=/s/$/, stdout/' $(ls -d apache-karaf-*)/etc/org.ops4j.pax.logging.cfg
63
Jonathan Hart15a71d82017-07-20 16:14:21 -070064LABEL 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"
alshabib187f1722015-06-23 16:15:50 -070070
71# Ports
Charles Chan45624b82015-08-24 00:29:20 +080072# 6653 - OpenFlow
Jonathan Hart77daee82017-01-16 14:29:20 -080073# 6640 - OVSDB
alshabib187f1722015-06-23 16:15:50 -070074# 8181 - GUI
75# 8101 - ONOS CLI
Jonathan Hart15a71d82017-07-20 16:14:21 -070076# 9876 - ONOS intra-cluster communication
Jonathan Hart77daee82017-01-16 14:29:20 -080077EXPOSE 6653 6640 8181 8101 9876
alshabib187f1722015-06-23 16:15:50 -070078
79# Get ready to run command
David Bainbridgeff4fb042015-08-17 12:53:29 -070080ENTRYPOINT ["./bin/onos-service"]
Jonathan Hart3e864192017-07-20 19:24:49 -070081CMD ["server"]