Skip to content

Commit c123b29

Browse files
committed
Provide a container for building Envoy on Oracle Linux 8.
Also add instructions about how to run an Oracle Linux 8 Envoy binary on a CentOS 7 host.
1 parent b0452fc commit c123b29

File tree

4 files changed

+123
-1
lines changed

4 files changed

+123
-1
lines changed

azure-pipelines.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
centos:
1313
OS_DISTRO: centos
1414
PUSH_GCR_IMAGE: false
15+
oraclelinux:
16+
OS_DISTRO: oraclelinux
17+
PUSH_GCR_IMAGE: false
1518
dependsOn: []
1619
timeoutInMinutes: 120
1720
pool:

build_container/CENTOS7_BUILD_STATUS.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
You are strongly encouraged to test the produced Envoy binary on CentOS 7 yourselves to ensure that it satisfies your required functionality and operates as expected.
22

3+
## Version 1.25.x
4+
If you need to run this version of Envoy on CentOS 7, your best bet is to use an Envoy binary built on Oracle Linux 8 and an updated version of glibc. CentOS 7 only comes with glibc 2.17, but the Envoy binary built on Oracle Linux 8 depends on a newer version of glibc, so you have to install a newer version on your system. Be careful not to override the existing version of glibc. Here are the rough instructions for accomplishing this:
5+
1. Use the Oracle Linux 8 image in this repo to build envoy.
6+
2. Copy the resulting Envoy binary to a CentOS 7 host.
7+
3. Install glibc 2.28 on the CentOS 7 host. This is the only version of glibc that has been tested with Envoy 1.25.x on CentOS 7.
8+
1. One option is to compile it from source.
9+
```
10+
wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
11+
tar zxvf glibc-2.28.tar.gz
12+
cd glibc-2.28
13+
mkdir build
14+
cd build
15+
../configure --prefix=/opt/glibc-2.28
16+
make -j4
17+
sudo make install
18+
```
19+
2. Another option is to download a pre-built RPM and extract it to a specific directory.
20+
```
21+
mkdir /opt/glibc-2.28
22+
cd /opt/glibc-2.28
23+
wget https://rpmfind.net/linux/centos/8-stream/BaseOS/x86_64/os/Packages/glibc-2.28-155.el8.x86_64.rpm
24+
rpm2cpio glibc-2.28-155.el8.x86_64.rpm | cpio -idmv
25+
rm glibc-2.28-155.el8.x86_64.rpm
26+
```
27+
4. Use [patchelf](https://github.com/NixOS/patchelf) to patch the Oracle Linux 8 Envoy binary to use the updated version of glibc ld-linux for its interpreter and set the rpath to include the libs from glibc. This allows you to start the binary using a newer glibc version that includes the features required by the Oracle Linux 8 binary. Without this, it will run the system ld-linux which is from glibc 2.17 on CentOS 7.
28+
```
29+
patchelf --set-interpreter '/opt/glibc-2.28/lib64/ld-linux-x86-64.so.2' --set-rpath '/opt/glibc-2.28/lib64/' ${path_to_envoy_binary}
30+
```
31+
5. You should now be able to run the Envoy binary on your CentOS 7 host.
32+
333
## Version 1.21.x
434
Envoy version 1.21 onwards cannot currently be compiled on CentOS 7.
535
@@ -48,4 +78,4 @@ Further investigation is needed to resolve this problem. Contributions are welco
4878
Envoy version 1.20 can be compiled on CentOS 7 using `clang and libc++`, but not `clang and libstdc++`, which throws an ambiguous function error. For more detail on this issue and a proposed fix see [here](https://github.com/envoyproxy/envoy/issues/19978).
4979

5080
## Version 1.19.x
51-
Envoy version 1.19 can be built using either `clang and libc++` or `clang and libstdc++` on CentOS 7.
81+
Envoy version 1.19 can be built using either `clang and libc++` or `clang and libstdc++` on CentOS 7.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM oraclelinux:8 as base
2+
3+
COPY ./build_container_common.sh /
4+
COPY ./build_container_centos.sh /
5+
6+
ENV PATH /opt/rh/rh-git218/root/usr/bin:/opt/rh/devtoolset-7/root/usr/bin:/opt/llvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
7+
8+
RUN mkdir /etc/sudoers.d
9+
RUN echo "Defaults secure_path = $PATH" > /etc/sudoers.d/path
10+
11+
RUN ./build_container_oraclelinux.sh
12+
ENV LC_ALL en_US.UTF-8
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
set -e
4+
ARCH="$(uname -m)"
5+
6+
yum-config-manager --enable ol8_codeready_builder
7+
yum update -y
8+
9+
yum install -y \
10+
binutils \
11+
cmake \
12+
gcc \
13+
git \
14+
glibc-langpack-en \
15+
glibc-locale-source \
16+
glibc-static \
17+
libstdc++-static \
18+
ncurses-compat-libs \
19+
ninja-build \
20+
perl \
21+
python3 \
22+
tcpdump \
23+
unzip \
24+
wget \
25+
xz \
26+
sudo
27+
28+
# set locale
29+
localedef -c -f UTF-8 -i en_US en_US.UTF-8
30+
export LC_ALL=en_US.UTF-8
31+
32+
# For LLVM to pick right libstdc++
33+
ln -s /opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9 /usr/lib/gcc/x86_64-redhat-linux
34+
35+
LLVM_VERSION=15.0.0
36+
37+
case $ARCH in
38+
'x86_64' )
39+
LLVM_DISTRO="x86_64-linux-gnu-rhel-8.4"
40+
LLVM_SHA256SUM="20b17fabc97b93791098e771adf18013c50eae2e45407f8bfa772883b6027d30"
41+
;;
42+
'aarch64' )
43+
LLVM_DISTRO="aarch64-linux-gnu"
44+
LLVM_SHA256SUM="527ed550784681f95ec7a1be8fbf5a24bd03d7da9bf31afb6523996f45670be3"
45+
;;
46+
esac
47+
48+
# httpd24 is equired by rh-git218
49+
echo "/opt/rh/httpd24/root/usr/lib64" > /etc/ld.so.conf.d/httpd24.conf
50+
ldconfig
51+
52+
# Setup tcpdump for non-root.
53+
groupadd -r pcap
54+
chgrp pcap /usr/sbin/tcpdump
55+
chmod 750 /usr/sbin/tcpdump
56+
setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
57+
58+
source ./build_container_common.sh
59+
60+
# compile proper version of gn, compatible with Oracle Linux's GLIBC version and
61+
# envoy wasm/v8 dependency
62+
# can be removed when the dependency will be updated
63+
git clone https://gn.googlesource.com/gn
64+
pushd gn
65+
# 45aa842fb41d79e149b46fac8ad71728856e15b9 is a hash of the version
66+
# before https://gn.googlesource.com/gn/+/46b572ce4ceedfe57f4f84051bd7da624c98bf01
67+
# as this commit expects envoy to rely on newer version of wasm/v8 with the fix
68+
# from https://github.com/v8/v8/commit/eac21d572e92a82f5656379bc90f8ecf1ff884fc
69+
# (versions 9.5.164 - 9.6.152)
70+
git checkout 45aa842fb41d79e149b46fac8ad71728856e15b9
71+
python3 build/gen.py
72+
ninja -C out
73+
mv -f out/gn /usr/local/bin/gn
74+
chmod +x /usr/local/bin/gn
75+
popd
76+
77+
yum clean all

0 commit comments

Comments
 (0)