Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Change Dockerfile to be Arm compatible
  • Loading branch information
lafonj committed Jul 23, 2018
1 parent 257eb6d commit 6af2d66
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 55 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Expand Up @@ -14,3 +14,4 @@ web/gui/src/main/webapp/tests/node_modules
web/gui/src/test/_karma/node_modules
web/gui/src/main/webapp/node_modules

Dockerfile
99 changes: 60 additions & 39 deletions Dockerfile
@@ -1,51 +1,71 @@
# First stage is the build environment
FROM sgrio/java-oracle:jdk_8 as builder
MAINTAINER Jonathan Hart <jono@opennetworking.org>

# Set the environment variables
ENV HOME /root
ENV BUILD_NUMBER docker
ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8

# Copy in the source
COPY . /src/onos/

# Build ONOS
# We extract the tar in the build environment to avoid having to put the tar
# in the runtime environment - this saves a lot of space
# FIXME - dependence on ONOS_ROOT and git at build time is a hack to work around
# build problems
WORKDIR /src/onos
RUN apt-get update && apt-get install -y zip python git bzip2 && \
export ONOS_ROOT=/src/onos && \
tools/build/onos-buck build onos && \
mkdir -p /src/tar && \
cd /src/tar && \
tar -xf /src/onos/buck-out/gen/tools/package/onos-package/onos.tar.gz --strip-components=1 && \
rm -rf /src/onos/buck-out .git
FROM debian:stretch as builder

RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates wget python maven git curl automake bison flex g++ git libboost-all-dev libevent-dev libtool make pkg-config thrift-compiler patch software-properties-common gnupg build-essential gperf ruby perl libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libpng-dev libjpeg-dev libx11-dev libxext-dev zip libssl1.0-dev unzip automake ninja-build golang

RUN apt-get update && \
add-apt-repository ppa:webupd8team/java -y && \
apt-get update && \
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections && \
apt-get install oracle-java8-installer oracle-java8-set-default -y --allow-unauthenticated

RUN git clone git://github.com/ariya/phantomjs.git \
&& cd phantomjs \
&& git checkout 2.1 \
&& git submodule init \
&& git submodule update \
&& cd /phantomjs \
&& python ./build.py --qt-config "-I /usr/include/openssl-1.0/ -L/usr/lib/openssl-1.0/" \
&& apt-get install -y libssl-dev nodejs phantomjs procps

RUN cd / \
&& export PROTOC_VERSION=3.0.2 \
&& git clone https://github.com/google/protobuf.git \
&& cd protobuf \
&& git checkout v$PROTOC_VERSION \
&& ./autogen.sh \
&& ./configure \
&& make \
&& make install \
&& export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH \
&& echo /usr/local/lib >> /etc/ld.so.conf \
&& ldconfig

COPY . /onos

RUN export QT_QPA_PLATFORM=minimal \
&& export ONOS_ROOT=/onos \
&& sed -i 's/jar -xf/unzip/g' /onos/tools/test/bin/onos-stage-apps \
&& cd /onos \
&& /onos/tools/build/onos-buck build onos --show-output -v 7 \
&& ONOS_VERSION=$(grep ONOS_VERSION onos.defs | xargs) \
&& echo ${ONOS_VERSION#*= } > VERSION


# Second stage is the runtime environment
FROM anapsix/alpine-java:8_server-jre
FROM debian:stretch

# Change to /root directory
RUN apk update && \
apk add curl && \
mkdir -p /root/onos
WORKDIR /root/onos
RUN apt-get update \
&& apt-get install -y curl software-properties-common \
&& add-apt-repository ppa:webupd8team/java -y \
&& apt-get update \
&& echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections \
&& apt-get install oracle-java8-installer oracle-java8-set-default -y --allow-unauthenticated \
&& mkdir -p /onos

# Install ONOS
COPY --from=builder /src/tar/ .
COPY --from=builder /onos/buck-out/gen/tools/package/onos-package/onos.tar.gz .
COPY --from=builder /onos/VERSION .

# Configure ONOS to log to stdout
RUN sed -ibak '/log4j.rootLogger=/s/$/, stdout/' $(ls -d apache-karaf-*)/etc/org.ops4j.pax.logging.cfg
RUN tar zxvf onos.tar.gz -C /onos/ \
&& rm onos.tar.gz \
&& export ONOS_VERSION=$(cat /VERSION) \
&& mv /onos/onos-$ONOS_VERSION /onos/onos \
&& cd onos/onos \
&& sed -ibak '/log4j.rootLogger=/s/$/, stdout/' $(ls -d apache-karaf-*)/etc/org.ops4j.pax.logging.cfg

LABEL org.label-schema.name="ONOS" \
org.label-schema.description="SDN Controller" \
org.label-schema.usage="http://wiki.onosproject.org" \
org.label-schema.url="http://onosproject.org" \
org.label-scheme.vendor="Open Networking Foundation" \
org.label-schema.schema-version="1.0"

# Ports
# 6653 - OpenFlow
Expand All @@ -56,5 +76,6 @@ LABEL org.label-schema.name="ONOS" \
EXPOSE 6653 6640 8181 8101 9876

# Get ready to run command
WORKDIR /onos/onos
ENTRYPOINT ["./bin/onos-service"]
CMD ["server"]
CMD ["server"]
13 changes: 8 additions & 5 deletions bucklets/grpc.bucklet
Expand Up @@ -5,19 +5,22 @@ include_defs('//bucklets/onos.bucklet')
DEFAULT_PROTOC_VERSION = '3.2.0'
DEFAULT_GRPC_PLUGIN_VERSION = '1.3.1'

PROTOC_RELEASE_BASE_URL = "https://github.com/google/protobuf/releases/download"
GRPC_PLUGIN_BASE_URL = "https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java"
PROTOC_RELEASE_BASE_URL = "http://artifacts.cachengo.com/protoc"
GRPC_PLUGIN_BASE_URL = "http://artifacts.cachengo.com/protoc-gen-grpc-java"

PROTOC_SHA1S = {
"protoc-3.0.2-linux-x86_64.zip":"779ed606f524eb2c8c116b0fce7a3bc6507769e7",
"protoc-3.0.2-osx-x86_64.zip":"f71d97affca4ffe32747772539c0bcbf76c9dc9b",
"protoc-3.2.0-linux-x86_64.zip":"f418d246d183a534d9bd749e614f639a55f6829b",
"protoc-3.2.0-osx-x86_64.zip":"81f4fac3200ba2cb12a98df0a9ee4d1c584e9210",
"protoc-3.2.0-linux-aarch64.zip":"779fee06c7e58ab4809fe5efb9a5ecaf0baf3e97",
"protoc-3.0.2-linux-aarch64.zip":"f704695b05320cb5e5a196dd3d32fa72575a4b64",
}

GRPC_JAVA_SHA1S = {
"protoc-gen-grpc-java-1.3.1-linux-x86_64.exe":"9598b00ad0f41a6bd6aeb01f647903dbc62792cc",
"protoc-gen-grpc-java-1.3.1-osx-x86_64.exe":"f4eccb96524b8b9f152024890550d9b88398b8cd"
"protoc-gen-grpc-java-1.3.1-osx-x86_64.exe":"f4eccb96524b8b9f152024890550d9b88398b8cd",
"protoc-gen-grpc-java-1.3.1-linux-aarch64.exe":"d1399e7d59382e8fb47e75cb70507a186f78216e"
}

#Returns the string for the OS and architecture of the system of the form 'OS-ARCH'
Expand All @@ -27,7 +30,7 @@ def get_system_arch():
arch = platform.machine()
if os == "darwin":
os = "osx"
return "%s-%s" % ( os, arch)
return "%s-%s" % (os, arch)

def fetch_protoc(
version
Expand All @@ -37,7 +40,7 @@ def fetch_protoc(
raise Exception('Cannot download %s, architecture or version not supported' % file_name)
remote_file(
name = 'protoc-release-' + version,
url = PROTOC_RELEASE_BASE_URL + '/v' + version + '/' + file_name,
url = PROTOC_RELEASE_BASE_URL + '/' + version + '/' + file_name,
sha1 = PROTOC_SHA1S[file_name],
)
genrule(
Expand Down
18 changes: 13 additions & 5 deletions bucklets/node.bucklet
@@ -1,20 +1,28 @@
import platform

NODE_RELEASE_BASE_URL = "https://nodejs.org/dist/"

NODE_SHA1S = {
"node-v8.1.2-linux-x64.tar.gz":"61a609c83e2d3458cc2301a63b212a97e6b9f809",
"node-v8.1.2-darwin-x64.tar.gz":"a8b31fd645480661a8a777d9b4466dca0e6deb33",
"node-v8.11.1-linux-x64.tar.gz":"ee0213f62185c36121c2daf8dcacd34ade90b10c",
"node-v8.11.1-darwin-x64.tar.gz":"01effb57fa711aa258d7aab26c6615e1f8a64b1a"
"node-v8.11.1-darwin-x64.tar.gz":"01effb57fa711aa258d7aab26c6615e1f8a64b1a",
"node-v8.1.2-linux-arm64.tar.gz":"a66cbd136ee21507e91e4b1a5678b5585eae6239",
"node-v8.11.1-linux-arm64.tar.gz":"90b40e1cd66c0d00f96d16d1ad21f14da2579e36",
}

def get_system_arch():
import platform
os = platform.system().lower()
return os
arch = platform.machine()
if arch == "x86_64":
arch = "x64"
elif arch == "aarch64":
arch = "arm64"
return "%s-%s" % (os, arch)

def fetch_node(version):
file_name = "node-%s-%s-x64" % (version, get_system_arch())
file_fullname = "node-%s-%s-x64.tar.gz" % (version, get_system_arch())
file_name = "node-%s-%s" % (version, get_system_arch())
file_fullname = "node-%s-%s.tar.gz" % (version, get_system_arch())
if file_fullname not in NODE_SHA1S:
raise Exception("Cannot download %s, architecture or version not supported" % file_name)

Expand Down
5 changes: 3 additions & 2 deletions protocols/bmv2/thrift-api/BUCK
Expand Up @@ -8,10 +8,11 @@ BMV2_COMMIT = 'a3f0ebe4c0f10a656f8aa1ad68cb20402a62b0ee'
BMV2_BASEURL = 'https://cdn.rawgit.com/p4lang/behavioral-model/' + BMV2_COMMIT
BMV2_NAMESPACE = 'org.onosproject.bmv2.thriftapi'

THRIFT_EXE_BASEURL = 'https://cdn.rawgit.com/ccascone/mvn-thrift-compiler/1.1_0.9.3/exe/'
THRIFT_EXE_BASEURL = 'http://artifacts.cachengo.com/thrift-compiler/0.9.3/'
THRIFT_EXE_SHA1S = {
'thrift-linux-x86_64.exe':'9b7b5d6eabc9552b8227e8f63981bc15c0985dd5',
'thrift-osx-x86_64.exe':'b9215c5141f56fd277b7cf41d9745af847afe498'
'thrift-osx-x86_64.exe':'b9215c5141f56fd277b7cf41d9745af847afe498',
'thrift-linux-aarch64.exe':'40b6d01b8574b9d372ec42c4c14b99dad9fa1cfd'
}

def prebuilt_thrift_compiler():
Expand Down
8 changes: 4 additions & 4 deletions web/gui/BUCK
Expand Up @@ -33,7 +33,7 @@ RESOURCES = {
'WEB-INF/classes/onos.js': 'src/main/webapp/onos.js',
'WEB-INF/classes/nav.html': 'src/main/webapp/nav.html',
'WEB-INF/classes/app/view': 'src/main/webapp/app/view',
'WEB-INF/classes/raw': 'src/main/webapp/raw',
'WEB-INF/classes/raw': 'src/main/webapp/raw'
}

include_defs('//bucklets/node.bucklet')
Expand All @@ -44,7 +44,7 @@ fetch_node(version = NODE_VERSION)
export_file (
name = 'onos-tools-gui-exe',
src = sh_src,
visibility = [ 'PUBLIC' ],
visibility = [ 'PUBLIC' ]
)

genrule(
Expand All @@ -54,7 +54,7 @@ genrule(
+ ' $(location :node-release-' + NODE_VERSION + ') '
+ '$(location :node-bin-' + NODE_VERSION + ') > $OUT',
out = 'onos-tools-gui.log',
visibility = [ 'PUBLIC' ],
visibility = [ 'PUBLIC' ]
)

osgi_jar_with_tests (
Expand All @@ -63,5 +63,5 @@ osgi_jar_with_tests (
test_deps = TEST_DEPS,
include_resources = RESOURCES,
web_context = '/onos/ui',
do_javadocs = False,
do_javadocs = False
)

0 comments on commit 6af2d66

Please sign in to comment.