This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
122 lines (89 loc) · 3.01 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
121
122
FROM ubuntu:20.04 AS build-env
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install --yes --no-install-recommends \
apt-transport-https \
ca-certificates \
git \
gnupg \
software-properties-common \
wget \
&& wget -O - "https://apt.kitware.com/keys/kitware-archive-latest.asc" 2> /dev/null \
| gpg --dearmor - \
| apt-key add - \
&& apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main' \
&& wget -O - "https://apt.llvm.org/llvm-snapshot.gpg.key" 2> /dev/null \
| apt-key add - \
&& add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main" \
&& apt-get update \
&& apt-get install --yes --no-install-recommends \
cmake \
make \
libc++-11-dev \
libc++1-11 \
libc++abi-11-dev \
libc++abi1-11 \
clang-11 \
clang-tools-11 \
clang-tidy-11 \
clang-format-11 \
lldb-11 \
lld-11 \
&& rm -rf /var/lib/apt/lists/*
FROM build-env AS build
WORKDIR /root/malloc/
COPY . .
RUN cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_COMPILER="clang++-11" \
-DCMAKE_CXX_CLANG_TIDY="clang-tidy-11" \
-DCMAKE_CXX_FLAGS="-I/lib/llvm-11/include/c++/v1" \
-DCMAKE_EXE_LINKER_FLAGS="-L/usr/llvm-11/lib -Wl,-rpath,/lib/llvm-11/lib -v" \
-B build \
&& cmake --build build -v \
&& cmake --install build
FROM build AS test
WORKDIR build
ENTRYPOINT ["ctest", "--output-on-failure"]
FROM build-env AS malloc-installed
COPY --from=build /usr/local/lib/lib*malloc.a /usr/local/lib/
COPY --from=build /usr/local/include/malloc/* /usr/local/include/malloc/
COPY --from=build /usr/local/lib/cmake/malloc/* /usr/local/lib/cmake/malloc/
FROM malloc-installed AS example-c
WORKDIR /root/malloc/examples/c
COPY examples/c .
RUN cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER="clang-11" \
-DCMAKE_CXX_COMPILER="clang++-11" \
-DCMAKE_CXX_CLANG_TIDY="clang-tidy-11" \
-DCMAKE_CXX_FLAGS="-I/lib/llvm-11/include/c++/v1" \
-DCMAKE_EXE_LINKER_FLAGS="-L/usr/llvm-11/lib -Wl,-rpath,/lib/llvm-11/lib -v" \
-B build \
&& cmake --build build -v
CMD ["build/malloc_example_c"]
FROM malloc-installed AS example-cpp
WORKDIR /root/malloc/examples/cpp/malloc
COPY examples/cpp/malloc .
RUN cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_COMPILER="clang++-11" \
-DCMAKE_CXX_CLANG_TIDY="clang-tidy-11" \
-DCMAKE_CXX_FLAGS="-I/lib/llvm-11/include/c++/v1" \
-DCMAKE_EXE_LINKER_FLAGS="-L/usr/llvm-11/lib -Wl,-rpath,/lib/llvm-11/lib -v" \
-B build \
&& cmake --build build -v
CMD ["build/malloc_example_cpp"]
FROM malloc-installed AS example-cpp-new
WORKDIR /root/malloc/examples/cpp/new
COPY examples/cpp/new .
RUN cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_COMPILER="clang++-11" \
-DCMAKE_CXX_CLANG_TIDY="clang-tidy-11" \
-DCMAKE_CXX_FLAGS="-I/lib/llvm-11/include/c++/v1" \
-DCMAKE_EXE_LINKER_FLAGS="-L/usr/llvm-11/lib -Wl,-rpath,/lib/llvm-11/lib -v" \
-B build \
&& cmake --build build -v
CMD ["build/malloc_example_cpp_new"]
FROM test