forked from stratum/stratum
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.build
105 lines (91 loc) · 4.26 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
# Copyright 2018-present Open Networking Foundation
# SPDX-License-Identifier: Apache-2.0
ARG BAZELISK_VERSION=1.7.5
ARG PI_COMMIT=0fbdac256151eb1537cd5ebf19101d5df60767fa
ARG BMV2_COMMIT=498202d98d83a6c580aa86a3497b9b496bcd43b2
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
# 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 to build the kernel modules
# + libbz2-dev for tar archive p4_device_config format
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 python-pip python-dev python3-dev \
apt-transport-https libelf-dev libbz2-dev
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
# 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
# Bazelisk and Bazel
ADD .bazelversion .
ARG BAZELISK_VERSION
RUN wget 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 pip install setuptools wheel && \
pip install 'cpplint==1.*'
RUN wget -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
# Install git-lfs for OpenNSA
# TODO the curl line can be dropped in Debian 10
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
RUN apt-get install -y --no-install-recommends git-lfs && git lfs install