-
Notifications
You must be signed in to change notification settings - Fork 124
/
Dockerfile
120 lines (106 loc) · 4.12 KB
/
Dockerfile
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
119
120
# Copyright 2020-2023 Google LLC
#
# 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.
# This Dockerfile provides a base image with the libraries needed to compile
# and test CLIF preinstalled. Example workflow using this image:
#
# // Build docker image
# docker build $CLIF_DIR --tag clif --build-arg=UBUNTU_VERSION=18.04 ...
#
# // Configure build
# docker run --volume $CLIF_DIR:/clif --workdir /clif/build clif cmake ..
#
# // Build clif-matcher
# docker run --volume $CLIF_DIR:/clif --workdir /clif/build clif make clif-matcher
#
# // Run cc tests
# docker run --volume $CLIF_DIR:/clif --workdir /clif/build clif ctest
#
# This docker image can be customized using the following build args:
#
# UBUNTU_VERSION: one of tags listed on https://hub.docker.com/_/ubuntu
# ABSL_VERSION: one of abseil/abseil-cpp Github releases
# PROTOBUF_VERSION: one of protocolbuffers/protobuf Github releases
# PYTHON_VERSION: python version to use (>= 3.8)
ARG UBUNTU_VERSION=20.04
FROM ubuntu:${UBUNTU_VERSION}
ARG LLVM_VERSION_MAJOR=17
ARG ABSL_VERSION=20230125.1
ARG PROTOBUF_VERSION=22.0
ARG PYTHON_VERSION=3.10
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
curl \
gpg-agent \
g++ \
libtool \
make \
pkg-config \
software-properties-common \
wget \
unzip
# Configure LLVM apt repository
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
add-apt-repository "deb http://apt.llvm.org/$(lsb_release -sc)/ llvm-toolchain-$(lsb_release -sc)-${LLVM_VERSION_MAJOR} main"
# Install CLIF dependencies
RUN apt-get update && apt-get install -y \
clang-${LLVM_VERSION_MAJOR} \
libclang-${LLVM_VERSION_MAJOR}-dev \
libllvm${LLVM_VERSION_MAJOR} \
llvm-${LLVM_VERSION_MAJOR} \
llvm-${LLVM_VERSION_MAJOR}-dev \
llvm-${LLVM_VERSION_MAJOR}-linker-tools \
python3-dev \
zlib1g-dev \
libgtest-dev
# Configure deadsnakes PPA with the more recent versions of python packaged for
# Ubuntu. See https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
RUN add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y \
"python$PYTHON_VERSION-dev" \
"python$PYTHON_VERSION-distutils"
# Install latest version of pip since the version on ubuntu could be outdated
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
"python$PYTHON_VERSION" get-pip.py && \
rm get-pip.py
# Compile and install absl-cpp from source
RUN wget "https://github.com/abseil/abseil-cpp/archive/$ABSL_VERSION.tar.gz" && \
tar -xf "$ABSL_VERSION.tar.gz" && \
mkdir "abseil-cpp-$ABSL_VERSION/build" && \
cd "abseil-cpp-$ABSL_VERSION/build" && \
cmake .. -DBUILD_SHARED_LIBS=ON && \
make -j$(nproc) && \
make install && \
rm -rf "/abseil-cpp-$ABSL_VERSION" "/$ABSL_VERSION.tar.gz"
# Compile and install protobuf from source
RUN wget "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-$PROTOBUF_VERSION.tar.gz" && \
tar -xf "protobuf-$PROTOBUF_VERSION.tar.gz" && \
cd "protobuf-$PROTOBUF_VERSION" && \
cmake . -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_STANDARD=17 -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_ABSL_PROVIDER=package && \
make -j$(nproc) && \
make install && \
ldconfig && \
rm -rf "/protobuf-$PROTOBUF_VERSION" "/protobuf-$PROTOBUF_VERSION.tar.gz"
# Install googletest
RUN cd /usr/src/googletest && \
cmake . && \
make -j$(nproc) && \
make install
# Install python runtime and test dependencies
RUN "python$PYTHON_VERSION" -m pip install \
absl-py \
parameterized \
protobuf=="4.$PROTOBUF_VERSION" \
pyparsing==2.2.2