forked from stratum/stratum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.build
91 lines (80 loc) · 3.74 KB
/
Dockerfile.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#
# Copyright 2018-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
ARG BAZEL_VERSION=0.23.2
ARG PI_COMMIT=1539ecd8a50c159b011d9c5a9c0eba99f122a845
ARG BMV2_COMMIT=9ef324838b29419040b4f677a3ff65bc72405c44
ARG JDK_URL=https://mirror.bazel.build/openjdk/azul-zulu11.29.3-ca-jdk11.0.2/zulu11.29.3-ca-jdk11.0.2-linux_x64.tar.gz
ARG LLVM_REPO_NAME="deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch main"
# Reasonable for CI
ARG JOBS=2
FROM debian:9@sha256:75f7d0590b45561bfa443abad0b3e0f86e2811b1fc176f786cd30eb078d1846f
LABEL maintainer="Stratum dev <[email protected]>"
LABEL description="This Docker image sets up a development environment for Stratum"
ARG JOBS
# bazel dependencies
# + wget to download bazel binary
# + ca-certificates for wget HTPPS connection
# LLVM dependencies
# + gnupg2 for apt-key
# + software-properties-common for add-apt-repository
ENV PKG_DEPS pkg-config zip zlib1g-dev unzip python wget ca-certificates \
ssh git gdb vim emacs-nox sudo libudev-dev libjudy-dev bison flex \
libfl-dev libgmp-dev libi2c-dev python-yaml libyaml-dev build-essential \
lcov curl autoconf automake libtool libgmp-dev libpcap-dev \
libboost-thread-dev libboost-filesystem-dev libboost-program-options-dev \
gnupg2 software-properties-common
RUN apt-get update && \
apt-get install -y --no-install-recommends $PKG_DEPS
# LLVM toolchain
ARG LLVM_REPO_NAME
RUN wget --quiet -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
RUN add-apt-repository "$LLVM_REPO_NAME"
RUN apt-get update && \
apt-get install -y --no-install-recommends clang-format clang
ARG BAZEL_VERSION
RUN wget https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
chmod +x bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
rm -f bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
# Install java and lcov for Bazel coverage
ARG JDK_URL
ENV JAVA_HOME /usr/local/lib/jvm
RUN wget $JDK_URL -O $HOME/jdk_11.0.2.tar.gz && \
mkdir -p $JAVA_HOME && \
tar xf $HOME/jdk_11.0.2.tar.gz -C $JAVA_HOME --strip-components=1 && \
rm $HOME/jdk_11.0.2.tar.gz
ENV PATH=$PATH:/usr/local/lib/jvm/bin
ARG PI_COMMIT
RUN git clone https://github.com/p4lang/PI.git /tmp/PI && \
cd /tmp/PI && git checkout ${PI_COMMIT} && \
git submodule update --init --recursive && \
./autogen.sh && \
./configure --without-bmv2 --without-proto --without-fe-cpp \
--without-cli --without-internal-rpc && \
make -j${JOBS} && make install && ldconfig && \
rm -rf /tmp/PI
ARG BMV2_COMMIT
ENV BMV2_INSTALL /usr/local
RUN git clone https://github.com/p4lang/behavioral-model.git /tmp/bmv2 && \
cd /tmp/bmv2 && git checkout ${BMV2_COMMIT} && \
./autogen.sh && \
./configure --without-targets --with-pi --disable-elogger \
--without-nanomsg --without-thrift --prefix=${BMV2_INSTALL} \
CXXFLAGS="-I${PWD}/targets/simple_switch -DWITH_SIMPLE_SWITCH -isystem$BMV2_INSTALL/include -isystem$PI_INSTALL/include -L$PI_INSTALL/lib" && \
make -j${JOBS} && make install && ldconfig && \
cd targets/simple_switch && \
make -j${JOBS} && make install && ldconfig && \
rm -rf /tmp/bmv2