Skip to content

Commit a220a3e

Browse files
authored
clean up tools' build dockerfile (#545)
* clean up tools' build dockerfile Signed-off-by: Harper, Jason M <[email protected]> * remove commented-out Java installation from Dockerfile Signed-off-by: Harper, Jason M <[email protected]> --------- Signed-off-by: Harper, Jason M <[email protected]>
1 parent 9db2c7d commit a220a3e

File tree

1 file changed

+68
-24
lines changed

1 file changed

+68
-24
lines changed

tools/build.Dockerfile

Lines changed: 68 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,62 @@ ENV https_proxy=${https_proxy}
1616
ENV LANG=en_US.UTF-8
1717
ARG DEBIAN_FRONTEND=noninteractive
1818
ARG GO_VERSION=1.25.4
19-
RUN apt-get update && apt-get install -y apt-utils locales wget curl git netcat-openbsd software-properties-common jq zip unzip
19+
20+
# install minimum packages to add repositories
21+
RUN success=false; \
22+
for i in {1..5}; do \
23+
apt-get update && apt-get install -y \
24+
apt-utils locales software-properties-common \
25+
&& success=true && break; \
26+
echo "Retrying in 5 seconds... ($i/5)" && sleep 5; \
27+
done; \
28+
$success || (echo "Failed to install required packages after 5 attempts" && exit 1)
29+
30+
# generate locale
2031
RUN locale-gen en_US.UTF-8 && echo "LANG=en_US.UTF-8" > /etc/default/locale
21-
RUN for i in {1..5}; do \
22-
add-apt-repository ppa:git-core/ppa -y && break; \
32+
33+
# add git ppa for up-to-date git
34+
RUN success=false; \
35+
for i in {1..5}; do \
36+
add-apt-repository ppa:git-core/ppa -y && apt-get update \
37+
&& success=true && break; \
2338
echo "Retrying in 5 seconds... ($i/5)" && sleep 5; \
24-
done
25-
RUN for i in {1..5}; do \
26-
apt-get update && apt-get install -y git build-essential autotools-dev automake \
39+
done; \
40+
$success || (echo "Failed to add git PPA after 5 attempts" && exit 1)
41+
42+
# install packages required to build tools
43+
RUN success=false; \
44+
for i in {1..5}; do \
45+
apt-get install -y \
46+
wget curl netcat-openbsd jq zip unzip \
47+
git build-essential autotools-dev automake \
2748
gawk zlib1g-dev libtool libaio-dev libaio1 pandoc pkgconf libcap-dev docbook-utils \
28-
libreadline-dev default-jre default-jdk cmake flex bison gettext libssl-dev \
49+
libreadline-dev cmake flex bison gettext libssl-dev \
2950
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu cpp-aarch64-linux-gnu \
30-
upx \
31-
&& break; \
51+
&& success=true && break; \
3252
echo "Retrying in 5 seconds... ($i/5)" && sleep 5; \
33-
done
34-
ENV JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
35-
# need golang to build go tools
53+
done; \
54+
$success || (echo "Failed to install build tools after 5 attempts" && exit 1)
55+
56+
# need golang to build go tools like ethtool
3657
RUN rm -rf /usr/local/go && wget -qO- https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xz
3758
ENV PATH="${PATH}:/usr/local/go/bin"
59+
3860
# need up-to-date zlib (used by stress-ng static build) to fix security vulnerabilities
3961
RUN git clone https://github.com/madler/zlib.git \
4062
&& cd zlib \
4163
&& ./configure \
42-
&& make install
64+
&& make install \
65+
&& cp /usr/local/lib/libz.a /usr/lib/x86_64-linux-gnu/libz.a
66+
4367
# build zlib for aarch64
4468
RUN git clone https://github.com/madler/zlib.git zlib-aarch64 \
4569
&& cd zlib-aarch64 \
4670
&& CHOST=aarch64-linux-gnu ./configure --archs="" --static \
4771
&& make \
4872
&& cp libz.a /usr/lib/aarch64-linux-gnu/
4973

50-
RUN cp /usr/local/lib/libz.a /usr/lib/x86_64-linux-gnu/libz.a
51-
# Build third-party components
74+
# Build tools
5275
RUN mkdir workdir
5376
ADD . /workdir
5477
WORKDIR /workdir
@@ -63,17 +86,37 @@ ENV http_proxy=${http_proxy}
6386
ENV https_proxy=${https_proxy}
6487
ENV LANG=en_US.UTF-8
6588
ARG DEBIAN_FRONTEND=noninteractive
66-
RUN apt-get update && apt-get install -y apt-utils locales wget curl git netcat-openbsd software-properties-common jq zip unzip
89+
90+
# install minimum packages to add repositories
91+
RUN success=false; \
92+
for i in {1..5}; do \
93+
apt-get update && apt-get install -y \
94+
apt-utils locales software-properties-common \
95+
&& success=true && break; \
96+
echo "Retrying in 5 seconds... ($i/5)" && sleep 5; \
97+
done; \
98+
$success || (echo "Failed to install required packages after 5 attempts" && exit 1)
99+
100+
# generate locale
67101
RUN locale-gen en_US.UTF-8 && echo "LANG=en_US.UTF-8" > /etc/default/locale
68-
RUN for i in {1..5}; do \
69-
add-apt-repository ppa:git-core/ppa -y && break; \
102+
103+
# add git ppa for up-to-date git
104+
RUN success=false; \
105+
for i in {1..5}; do \
106+
add-apt-repository ppa:git-core/ppa -y && apt-get update \
107+
&& success=true && break; \
70108
echo "Retrying in 5 seconds... ($i/5)" && sleep 5; \
71-
done
109+
done; \
110+
$success || (echo "Failed to add git PPA after 5 attempts" && exit 1)
72111

73-
# Use relatively small ulimit. This is due to pycompile, see: https://github.com/MaastrichtUniversity/docker-dev/commit/97ab4fd04534f73c023371b07e188918b73ac9d0
112+
# install packages required to build perf and processwatch
113+
# Use relatively small ulimit. This is due to pycompile,
114+
# see: https://github.com/MaastrichtUniversity/docker-dev/commit/97ab4fd04534f73c023371b07e188918b73ac9d0
74115
# This works around python-pkg-resources taking a extremely long time to install
75-
RUN ulimit -n 4096 && for i in {1..5}; do \
116+
RUN ulimit -n 4096 && success=false; \
117+
for i in {1..5}; do \
76118
apt-get update && apt-get install -y \
119+
wget curl netcat-openbsd jq zip unzip \
77120
automake autotools-dev binutils-dev bison build-essential clang cmake debuginfod \
78121
default-jdk default-jre docbook-utils flex gawk git libaio-dev libaio1 \
79122
libbabeltrace-dev libbpf-dev libc6 libcap-dev libdw-dev libdwarf-dev libelf-dev \
@@ -82,10 +125,10 @@ RUN ulimit -n 4096 && for i in {1..5}; do \
82125
libzstd1 llvm-14 pandoc pkgconf python-setuptools python2-dev python3 python3-dev \
83126
python3-pip systemtap-sdt-dev zlib1g-dev libbz2-dev libcapstone-dev libtracefs-dev \
84127
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu cpp-aarch64-linux-gnu \
85-
upx \
86-
&& break; \
128+
&& success=true && break; \
87129
echo "Retrying in 5 seconds... ($i/5)" && sleep 5; \
88-
done
130+
done; \
131+
$success || (echo "Failed to install perf build tools after 5 attempts" && exit 1)
89132

90133
# libdwfl will dlopen libdebuginfod at runtime, may cause segment fault in static build, disable it. ref: https://github.com/vgteam/vg/pull/3600
91134
RUN wget https://sourceware.org/elfutils/ftp/0.190/elfutils-0.190.tar.bz2 \
@@ -117,6 +160,7 @@ RUN git clone https://git.code.sf.net/p/perfmon2/libpfm4 libpfm4-aarch64 \
117160
&& ARCH=arm64 CC=aarch64-linux-gnu-gcc make \
118161
&& cp lib/libpfm.a /usr/lib/aarch64-linux-gnu/
119162

163+
# build perf and processwatch
120164
ENV PATH="${PATH}:/usr/lib/llvm-14/bin"
121165
RUN mkdir workdir
122166
ADD . /workdir

0 commit comments

Comments
 (0)