forked from stratum/stratum
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile.build
119 lines (104 loc) · 4.82 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Copyright 2018-present Open Networking Foundation
# SPDX-License-Identifier: Apache-2.0
ARG BAZELISK_VERSION=1.8.0
ARG PI_COMMIT=a5fd855d4b3293e23816ef6154e83dc6621aed6a
ARG BMV2_COMMIT=c67becf3f8f8b9af5a41f11e00eb9a473912e310
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/buster/ llvm-toolchain-buster-11 main"
# Reasonable for CI
ARG JOBS=2
FROM debian:buster@sha256:e82e10f0b9560e5947a16eb28c2992ec03121fc8c9659bce0cc94c5b7b6178c9
LABEL maintainer="Stratum dev <stratum-dev@lists.stratumproject.org>"
LABEL description="This Docker image sets up a development environment for Stratum"
ARG JOBS
# zdata
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# bazelisk dependencies
# + wget to download bazelisk binary
# + ca-certificates for wget HTPPS connection
# LLVM dependencies
# + gnupg2 for apt-key
# + software-properties-common for add-apt-repository
# OpenNSA dependencies
# + libelf-dev to build the kernel modules
# BF SDE dependecies
# + libelf-dev gawk to build the kernel modules
# Tools and libraries for p4lang/target-syslibs and p4lang/target-utils
# + cmake libedit-dev expat
# Tools to patch the SONiC kernel headers
# + rsync
ENV PKG_DEPS pkg-config zip zlib1g-dev unzip wget ca-certificates \
ssh git gdb vim emacs-nox sudo libudev-dev libjudy-dev bison flex \
libfl-dev libgmp-dev libi2c-dev python3-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 python3-pip python3-dev \
apt-transport-https libelf-dev cmake libedit-dev expat libbz2-dev rsync gawk
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-11 clang-11 llvm-11
# Versioned LLVM releases don't come with the meta packages for the
# clang -> clang-11 symlinks. We create them manually here.
RUN ln -s ../lib/llvm-11/bin/clang /usr/bin/clang
RUN ln -s ../lib/llvm-11/bin/clang++ /usr/bin/clang++
RUN ln -s ../lib/llvm-11/bin/clang-format /usr/bin/clang-format
# Install java for Bazel coverage report
ARG JDK_URL
ENV JAVA_HOME /usr/local/lib/jvm
RUN wget --quiet $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
# TODO(max): switch back to upstream repo once merged
RUN git clone https://github.com/pudelkoM/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 && \
cp /tmp/bmv2/tools/veth* ${BMV2_INSTALL}/bin/ && \
rm -rf /tmp/bmv2
# Bazelisk and Bazel
ADD .bazelversion .
ADD BUILD .
ADD WORKSPACE .
ARG BAZELISK_VERSION
RUN wget --quiet https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VERSION}/bazelisk-linux-amd64 && \
mv bazelisk-linux-amd64 /usr/local/bin/bazel && \
chmod +x /usr/local/bin/bazel && \
bazel version
# Tools for style and license checking
RUN pip3 install setuptools wheel && \
pip3 install 'cpplint==1.*'
RUN wget --quiet -O /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/4.0.0/buildifier
RUN chmod +x /usr/local/bin/buildifier
# Docker CLI for CI builds
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
RUN apt-get update && apt-get install -y --no-install-recommends docker-ce-cli
# Bazel uses "python" instead of "python3" for some cases.
RUN ln -s /usr/bin/python3 /usr/bin/python