Skip to content

Commit

Permalink
[v14] Remove custom BoringSSL build (#34942)
Browse files Browse the repository at this point in the history
The `boring` crate will compile BoringSSL on demand.

Remove unneeded Clang 7 build and replace Clang 10 with Clang 12.
BoringSSL in FIPS mode explicitly requires Clang 12.0.0, while libbpf
and related tools only require Clang 10+, so standardized everything
on Clang 12.0.0 so that we don't need multiple Clang installations.

This also required libbpf to be bumped, as 1.0.1 no longer compiled.
Both 1.1.x and 1.2.x seem to build fine, so went ahead and bumped to
1.2.2 (latest libbpf). As a result, `aquasecurity/libbpfgo` was also
bumped to match the new version.

Additionally, add a few missing git commit hash validations that were
noticed as all the `Dockerfile`s were being reviewed/updated.
  • Loading branch information
reedloden authored Nov 27, 2023
1 parent 6668d40 commit 5ee7358
Show file tree
Hide file tree
Showing 16 changed files with 215 additions and 182 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build-centos7-assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
runner: [ ubuntu-22.04-32core, ['self-hosted', 'linux', 'arm64'] ]
# Use bigger worker. Clang takes a while to build.
runs-on: ${{ matrix.runner }}
timeout-minutes: 720

permissions:
contents: read
Expand All @@ -36,6 +37,14 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Ensure required packages are installed
run: |
os_id=$(awk -F= '/^ID/{print $2}' /etc/os-release)
if [[ ! "$os_id" =~ ^ubuntu.* ]]; then
sudo dnf upgrade-minimal -y
sudo dnf install -y make
fi
# We need to keep env vars in sync, so, we can't use standard build actions
- name: Build buildbox assets image
run: cd build.assets && make build-centos7-assets
Expand Down
12 changes: 8 additions & 4 deletions build.assets/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# syntax=docker/dockerfile:1

###################################################################################
# #
# DO NOT USE FOR PRODUCTION BUILD OR ANYTHING OTHER THAN CI TESTING! #
Expand Down Expand Up @@ -82,7 +84,7 @@ RUN mkdir -p /opt && cd /opt && \
curl -fsSL https://github.com/libbpf/libbpf/archive/refs/tags/v${LIBBPF_VERSION}.tar.gz | tar xz && \
cd /opt/libbpf-${LIBBPF_VERSION}/src && \
make && \
BUILD_STATIC_ONLY=y DESTDIR=/opt/libbpf make install
BUILD_STATIC_ONLY=y DESTDIR=/opt/libbpf make install install_uapi_headers

## BUILDBOX ###################################################################
#
Expand Down Expand Up @@ -251,9 +253,11 @@ RUN make -C /opt/pam_teleport install
ENV SOFTHSM2_PATH "/usr/lib/softhsm/libsofthsm2.so"

# Install bats.
RUN curl -fsSL https://github.com/bats-core/bats-core/archive/v1.2.1.tar.gz | tar -xz && \
cd bats-core-1.2.1 && ./install.sh /usr/local && cd .. && \
rm -r bats-core-1.2.1
RUN git clone --depth=1 https://github.com/bats-core/bats-core.git -b v1.2.1 && \
cd bats-core && \
[ "$(git rev-parse HEAD)" = 'dcaec03e32e0b152f8ef9cf14b75296cf5caeaff' ] && \
./install.sh /usr/local && cd .. && \
rm -r bats-core

# Install shellcheck.
RUN scversion='v0.9.0' && \
Expand Down
2 changes: 2 additions & 0 deletions build.assets/Dockerfile-arm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# syntax=docker/dockerfile:1

# This Dockerfile is used to build Teleport on ARM only.
# We are using the official Debian 12 image as a base image
# because the final binary must be compatible with distroless
Expand Down
93 changes: 80 additions & 13 deletions build.assets/Dockerfile-centos7
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@ ARG RUST_VERSION
# git2 packages are not available on ARM64, so we need to build it from source.
FROM centos:7 AS git2

ARG BUILDARCH
ARG TARGETARCH
ARG DEVTOOLSET

# devtoolset-12 is only in CentOS buildlogs. The rpms are unsigned since they never were
# published to the official CentOS SCL repos.
ENV DEVTOOLSET=${DEVTOOLSET} \
TARGETARCH=${TARGETARCH}

RUN bash -c 'if [ "${TARGETARCH}" = "arm64" ]; then export TARGETARCH="aarch64"; fi; \
echo -e "[${DEVTOOLSET}-build]\nname=${DEVTOOLSET} - Build\nbaseurl=https://buildlogs.centos.org/c7-${DEVTOOLSET}.${TARGETARCH}/\ngpgcheck=0\nenabled=1" > /etc/yum.repos.d/${DEVTOOLSET}-build.repo'

# Install required dependencies.
RUN yum groupinstall -y 'Development Tools' && \
yum install -y \
ca-certificates \
Expand All @@ -20,14 +31,18 @@ RUN yum groupinstall -y 'Development Tools' && \
yum update -y && \
yum -y install centos-release-scl-rh && \
yum install -y \
centos-release-scl \
${DEVTOOLSET}-gcc* \
${DEVTOOLSET}-make && \
centos-release-scl && \
yum clean all

# As mentioned above, these packages are unsigned.
RUN yum install --nogpgcheck -y \
${DEVTOOLSET}-gcc* \
${DEVTOOLSET}-make && \
yum clean all

RUN wget https://github.com/git/git/archive/refs/tags/v2.42.0.tar.gz && \
tar xf v2.42.0.tar.gz && \
cd git-2.42.0/ && \
RUN git clone --depth=1 https://github.com/git/git.git -b v2.42.0 && \
cd git && \
[ "$(git rev-parse HEAD)" = '43c8a30d150ecede9709c1f2527c8fba92c65f40' ] && \
scl enable ${DEVTOOLSET} "make configure && \
./configure --prefix=/usr/local && \
make -j"$(nproc)" all && \
Expand All @@ -43,20 +58,33 @@ FROM ghcr.io/gravitational/teleport-buildbox-centos7-assets:teleport14-${BUILDAR
FROM centos:7 AS libfido2

ARG DEVTOOLSET
ARG TARGETARCH

# devtoolset-12 is only in CentOS buildlogs. The rpms are unsigned since they never were
# published to the official CentOS SCL repos.
ENV DEVTOOLSET=${DEVTOOLSET} \
TARGETARCH=${TARGETARCH}

RUN bash -c 'if [ "${TARGETARCH}" = "arm64" ]; then export TARGETARCH="aarch64"; fi; \
echo -e "[${DEVTOOLSET}-build]\nname=${DEVTOOLSET} - Build\nbaseurl=https://buildlogs.centos.org/c7-${DEVTOOLSET}.${TARGETARCH}/\ngpgcheck=0\nenabled=1" > /etc/yum.repos.d/${DEVTOOLSET}-build.repo'

RUN yum groupinstall -y 'Development Tools' && \
yum install -y epel-release && \
yum install -y centos-release-scl-rh && \
yum update -y && \
yum install -y \
cmake3 \
${DEVTOOLSET}-gcc* \
git \
libudev-devel \
perl-IPC-Cmd \
zlib-devel && \
yum clean all

# As mentioned above, these packages are unsigned.
RUN yum install --nogpgcheck -y \
${DEVTOOLSET}-gcc* && \
yum clean all

# Install libudev-zero.
# libudev-zero replaces systemd's libudev.
RUN git clone --depth=1 https://github.com/illiliti/libudev-zero.git -b 1.0.3 && \
Expand Down Expand Up @@ -108,6 +136,15 @@ RUN git clone --depth=1 https://github.com/Yubico/libfido2.git -b 1.13.0 && \
FROM centos:7 AS libbpf

ARG DEVTOOLSET
ARG TARGETARCH

# devtoolset-12 is only in CentOS buildlogs. The rpms are unsigned since they never were
# published to the official CentOS SCL repos.
ENV DEVTOOLSET=${DEVTOOLSET} \
TARGETARCH=${TARGETARCH}

RUN bash -c 'if [ "${TARGETARCH}" = "arm64" ]; then export TARGETARCH="aarch64"; fi; \
echo -e "[${DEVTOOLSET}-build]\nname=${DEVTOOLSET} - Build\nbaseurl=https://buildlogs.centos.org/c7-${DEVTOOLSET}.${TARGETARCH}/\ngpgcheck=0\nenabled=1" > /etc/yum.repos.d/${DEVTOOLSET}-build.repo'

# Install required dependencies.
RUN yum groupinstall -y 'Development Tools' && \
Expand All @@ -116,25 +153,38 @@ RUN yum groupinstall -y 'Development Tools' && \
yum -y install centos-release-scl-rh && \
yum install -y \
centos-release-scl \
${DEVTOOLSET}-gcc* \
${DEVTOOLSET}-make \
elfutils-libelf-devel-static \
scl-utils && \
yum clean all

# As mentioned above, these packages are unsigned.
RUN yum install --nogpgcheck -y \
${DEVTOOLSET}-gcc* \
${DEVTOOLSET}-make && \
yum clean all

# Install libbpf - compile with a newer GCC. The one installed by default is not able to compile it.
# BUILD_STATIC_ONLY disables libbpf.so build as we don't need it.
ARG LIBBPF_VERSION
RUN mkdir -p /opt && cd /opt && \
curl -fsSL https://github.com/libbpf/libbpf/archive/refs/tags/v${LIBBPF_VERSION}.tar.gz | tar xz && \
cd /opt/libbpf-${LIBBPF_VERSION}/src && \
scl enable ${DEVTOOLSET} "make && BUILD_STATIC_ONLY=y DESTDIR=/opt/libbpf make install"
scl enable ${DEVTOOLSET} "make && BUILD_STATIC_ONLY=y DESTDIR=/opt/libbpf make install install_uapi_headers"

## LIBPCSCLITE #####################################################################

FROM centos:7 AS libpcsclite

ARG DEVTOOLSET
ARG TARGETARCH

# devtoolset-12 is only in CentOS buildlogs. The rpms are unsigned since they never were
# published to the official CentOS SCL repos.
ENV DEVTOOLSET=${DEVTOOLSET} \
TARGETARCH=${TARGETARCH}

RUN bash -c 'if [ "${TARGETARCH}" = "arm64" ]; then export TARGETARCH="aarch64"; fi; \
echo -e "[${DEVTOOLSET}-build]\nname=${DEVTOOLSET} - Build\nbaseurl=https://buildlogs.centos.org/c7-${DEVTOOLSET}.${TARGETARCH}/\ngpgcheck=0\nenabled=1" > /etc/yum.repos.d/${DEVTOOLSET}-build.repo'

# Install required dependencies.
RUN yum groupinstall -y 'Development Tools' && \
Expand All @@ -145,6 +195,10 @@ RUN yum groupinstall -y 'Development Tools' && \
libudev-devel \
scl-utils \
centos-release-scl \
yum clean all

# As mentioned above, these packages are unsigned.
RUN yum install --nogpgcheck -y \
${DEVTOOLSET}-gcc* && \
yum clean all

Expand All @@ -169,21 +223,28 @@ ENV LANGUAGE=en_US.UTF-8 \
ARG GOLANG_VERSION
ARG RUST_VERSION
ARG DEVTOOLSET
ARG TARGETARCH

ARG UID
ARG GID
RUN (groupadd ci --gid=$GID -o && useradd ci --uid=$UID --gid=$GID --create-home --shell=/bin/sh && \
mkdir -p -m0700 /var/lib/teleport && chown -R ci /var/lib/teleport)

# devtoolset-12 is only in CentOS buildlogs. The rpms are unsigned since they never were
# published to the official CentOS SCL repos.
ENV DEVTOOLSET=${DEVTOOLSET} \
TARGETARCH=${TARGETARCH}

RUN bash -c 'if [ "${TARGETARCH}" = "arm64" ]; then export TARGETARCH="aarch64"; fi; \
echo -e "[${DEVTOOLSET}-build]\nname=${DEVTOOLSET} - Build\nbaseurl=https://buildlogs.centos.org/c7-${DEVTOOLSET}.${TARGETARCH}/\ngpgcheck=0\nenabled=1" > /etc/yum.repos.d/${DEVTOOLSET}-build.repo'

RUN yum groupinstall -y 'Development Tools' && \
yum install -y epel-release && \
yum update -y && \
yum -y install centos-release-scl-rh && \
yum install -y \
#required by libbpf
centos-release-scl \
# required by libbpf
${DEVTOOLSET}-* \
centos-release-scl \
# required by libbpf
elfutils-libelf-devel-static \
net-tools \
Expand All @@ -199,6 +260,12 @@ RUN yum groupinstall -y 'Development Tools' && \
yum clean all && \
localedef -c -i en_US -f UTF-8 en_US.UTF-8

# As mentioned above, these packages are unsigned.
RUN yum install --nogpgcheck -y \
${DEVTOOLSET}-gcc* \
${DEVTOOLSET}-make && \
yum clean all

# Override the old git in /usr/local installed by yum. We need git 2+ on GitHub Actions.
COPY --from=git2 /opt/git /

Expand Down
38 changes: 29 additions & 9 deletions build.assets/Dockerfile-centos7-assets
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# syntax=docker/dockerfile:1

FROM centos:7 AS centos-devtoolset

ARG DEVTOOLSET
ARG TARGETARCH

# devtoolset-12 is only in CentOS buildlogs. The rpms are unsigned since they never were
# published to the official CentOS SCL repos.
RUN if [ "${TARGETARCH}" = "arm64" ]; then export TARGETARCH="aarch64"; fi && \
cat <<EOF > /etc/yum.repos.d/${DEVTOOLSET}-build.repo
[${DEVTOOLSET}-build]
name=${DEVTOOLSET} - Build
baseurl=https://buildlogs.centos.org/c7-${DEVTOOLSET}.${TARGETARCH}/
gpgcheck=0
enabled=1
EOF

# Install required dependencies.
RUN yum groupinstall -y 'Development Tools' && \
Expand All @@ -12,10 +26,6 @@ RUN yum groupinstall -y 'Development Tools' && \
centos-release-scl \
# required by Clang/LLVM
cmake3 \
# required by libbpf and Clang
${DEVTOOLSET}-gcc* \
# required by libbpf
${DEVTOOLSET}-make \
# required by libbpf
elfutils-libelf-devel \
# required by libbpf
Expand All @@ -29,19 +39,29 @@ RUN yum groupinstall -y 'Development Tools' && \
zlib-static && \
yum clean all

# As mentioned above, these packages are unsigned.
RUN yum install --nogpgcheck -y \
${DEVTOOLSET}-gcc* \
${DEVTOOLSET}-make && \
yum clean all

# Use just created devtool image with newer GCC and Cmake
FROM centos-devtoolset as clang10
FROM centos-devtoolset as clang12

ARG DEVTOOLSET

# Compile Clang 10.0.1 from source. It is needed to create BPF files.
# Centos 7 doesn't provide it as a package unfortunately.
# Compile Clang 12.0.0 from source. It is needed to create BoringSSL and BPF files.
# CentOS 7 doesn't provide it as a package unfortunately.
# This version of Clang is explicitly required for FIPS compliance when building BoringSSL.
# For more information please refer to the section 12. Guidance and Secure Operation of:
# https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp4407.pdf
# LLVM_INCLUDE_BENCHMARKS must be off, otherwise compilation fails,
# CLANG_BUILD_TOOLS must be on, it builds clang binary,
# LLVM_BUILD_TOOLS must be on, it builds llvm-strip binary.
# the rest is disabled to speedup the compilation.
RUN git clone --branch llvmorg-10.0.1 --depth=1 https://github.com/llvm/llvm-project.git && \
RUN git clone --branch llvmorg-12.0.0 --depth=1 https://github.com/llvm/llvm-project.git && \
cd llvm-project/ && \
[ "$(git rev-parse HEAD)" = 'd28af7c654d8db0b68c175db5ce212d74fb5e9bc' ] && \
mkdir build && cd build/ && \
scl enable ${DEVTOOLSET} 'bash -c "cmake3 \
-DCLANG_BUILD_TOOLS=ON \
Expand All @@ -68,4 +88,4 @@ RUN git clone --branch llvmorg-10.0.1 --depth=1 https://github.com/llvm/llvm-pro
FROM scratch AS buildbox-centos7-assets

# Copy Clang into the final image.
COPY --from=clang10 /opt/llvm /opt/llvm/
COPY --from=clang12 /opt/llvm /opt/llvm/
Loading

0 comments on commit 5ee7358

Please sign in to comment.