Merge pull request #10442 from Sumynwa/sumsharma/tools_use_ubuntu_static_build

ci: Use ubuntu for static building of kata tools.
This commit is contained in:
Fabiano Fidêncio 2024-11-01 16:04:31 +01:00 committed by GitHub
commit 2efcb442f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 58 additions and 38 deletions

View File

@ -57,7 +57,10 @@ endef
kata-tarball: | all-parallel merge-builds kata-tarball: | all-parallel merge-builds
copy-scripts-for-the-agent-build: copy-scripts-for-the-agent-build:
${MK_DIR}/kata-deploy-copy-libseccomp-installer.sh ${MK_DIR}/kata-deploy-copy-libseccomp-installer.sh "agent"
copy-scripts-for-the-tools-build:
${MK_DIR}/kata-deploy-copy-libseccomp-installer.sh "tools"
all-parallel: all-parallel:
${MAKE} -f $(MK_PATH) all -j $(shell nproc) V= ${MAKE} -f $(MK_PATH) all -j $(shell nproc) V=
@ -74,7 +77,7 @@ serial-targets:
agent-tarball: copy-scripts-for-the-agent-build agent-tarball: copy-scripts-for-the-agent-build
${MAKE} $@-build ${MAKE} $@-build
agent-ctl-tarball: agent-ctl-tarball: copy-scripts-for-the-tools-build
${MAKE} $@-build ${MAKE} $@-build
busybox-tarball: busybox-tarball:
@ -92,13 +95,13 @@ cloud-hypervisor-glibc-tarball:
firecracker-tarball: firecracker-tarball:
${MAKE} $@-build ${MAKE} $@-build
genpolicy-tarball: genpolicy-tarball: copy-scripts-for-the-tools-build
${MAKE} $@-build ${MAKE} $@-build
pause-image-tarball: pause-image-tarball:
${MAKE} $@-build ${MAKE} $@-build
kata-ctl-tarball: kata-ctl-tarball: copy-scripts-for-the-tools-build
${MAKE} $@-build ${MAKE} $@-build
kata-manager-tarball: kata-manager-tarball:
@ -158,13 +161,13 @@ rootfs-initrd-confidential-tarball: agent-tarball pause-image-tarball coco-guest
rootfs-initrd-tarball: agent-tarball rootfs-initrd-tarball: agent-tarball
${MAKE} $@-build ${MAKE} $@-build
runk-tarball: runk-tarball: copy-scripts-for-the-tools-build
${MAKE} $@-build ${MAKE} $@-build
shim-v2-tarball: shim-v2-tarball:
${MAKE} $@-build ${MAKE} $@-build
trace-forwarder-tarball: trace-forwarder-tarball: copy-scripts-for-the-tools-build
${MAKE} $@-build ${MAKE} $@-build
virtiofsd-tarball: virtiofsd-tarball:

View File

@ -985,6 +985,10 @@ install_tools_helper() {
"${final_tarball_path}" \ "${final_tarball_path}" \
&& return 0 && return 0
export LIBSECCOMP_VERSION="$(get_from_kata_deps ".externals.libseccomp.version")"
export LIBSECCOMP_URL="$(get_from_kata_deps ".externals.libseccomp.url")"
export GPERF_VERSION="$(get_from_kata_deps ".externals.gperf.version")"
export GPERF_URL="$(get_from_kata_deps ".externals.gperf.url")"
info "build static ${tool}" info "build static ${tool}"
${tools_builder} ${tool} ${tools_builder} ${tool}

View File

@ -13,7 +13,7 @@ set -o errtrace
script_dir=$(dirname "$(readlink -f "$0")") script_dir=$(dirname "$(readlink -f "$0")")
install_libseccomp_script_src="${script_dir}/../../../../ci/install_libseccomp.sh" install_libseccomp_script_src="${script_dir}/../../../../ci/install_libseccomp.sh"
install_libseccomp_script_dest="${script_dir}/../../static-build/agent/install_libseccomp.sh" install_libseccomp_script_dest="${script_dir}/../../static-build/$1/install_libseccomp.sh"
cp "${install_libseccomp_script_src}" "${install_libseccomp_script_dest}" cp "${install_libseccomp_script_src}" "${install_libseccomp_script_dest}"

View File

@ -2,35 +2,49 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
FROM alpine:3.18 FROM ubuntu:20.04
ARG GO_TOOLCHAIN ARG GO_TOOLCHAIN
ARG RUST_TOOLCHAIN ARG RUST_TOOLCHAIN
COPY install_libseccomp.sh /usr/bin/install_libseccomp.sh
ENV DEBIAN_FRONTEND=noninteractive
ENV RUSTUP_HOME="/opt/rustup" ENV RUSTUP_HOME="/opt/rustup"
ENV CARGO_HOME="/opt/cargo" ENV CARGO_HOME="/opt/cargo"
ENV PATH="/opt/cargo/bin/:${PATH}" ENV PATH="/opt/cargo/bin/:${PATH}"
ENV OPT_LIB="/opt/lib"
ENV LIBC="musl"
ENV LIBSECCOMP_LINK_TYPE=static ENV LIBSECCOMP_LINK_TYPE=static
ENV LIBSECCOMP_LIB_PATH=/usr/lib ENV LIBSECCOMP_LIB_PATH=${OPT_LIB}
SHELL ["/bin/ash", "-o", "pipefail", "-c"] ENV PKG_CONFIG_PATH=${OPT_LIB}/pkgconfig:$PKG_CONFIG_PATH
RUN mkdir ${RUSTUP_HOME} ${CARGO_HOME} && chmod -R a+rwX ${RUSTUP_HOME} ${CARGO_HOME} SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apk --no-cache add \ RUN mkdir ${RUSTUP_HOME} ${CARGO_HOME} && chmod -R a+rwX /opt
bash \
clang \ RUN apt-get update && \
cmake \ apt-get --no-install-recommends -y install \
curl \ ca-certificates \
gcc \ clang \
git \ cmake \
libcap-ng-static \ curl \
libseccomp-static \ g++ \
openssl-dev \ gcc \
openssl-libs-static \ git \
make \ libssl-dev \
musl-dev \ make \
perl \ musl-tools \
protoc && \ perl \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${RUST_TOOLCHAIN} protobuf-compiler && \
apt-get clean && rm -rf /var/lib/apt/lists/ && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${RUST_TOOLCHAIN}
# Tools only build for x86_64
RUN rustup target add x86_64-unknown-linux-musl
# cmake looks for musl binutils
# For setting CMAKE_AR, find_program searches for musl-ar.
# Symlink to system ar.
RUN ln -s "$(which ar)" /usr/bin/musl-ar

View File

@ -12,17 +12,12 @@ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/../../scripts/lib.sh" source "${script_dir}/../../scripts/lib.sh"
init_env() {
source "$HOME/.cargo/env"
export LIBC=musl
export LIBSECCOMP_LINK_TYPE=static
export LIBSECCOMP_LIB_PATH=/usr/lib
extra_rust_flags=" -C link-self-contained=yes"
}
build_tool_from_source() { build_tool_from_source() {
RUSTFLAGS=" -C link-self-contained=yes"
export LIBC=musl
/usr/bin/install_libseccomp.sh /opt /opt
tool=${1} tool=${1}
echo "build ${tool} from source" echo "build ${tool} from source"

View File

@ -26,6 +26,10 @@ docker pull ${container_image} || \
push_to_registry "${container_image}") push_to_registry "${container_image}")
docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \
--env LIBSECCOMP_VERSION=${LIBSECCOMP_VERSION} \
--env LIBSECCOMP_URL=${LIBSECCOMP_URL} \
--env GPERF_VERSION=${GPERF_VERSION} \
--env GPERF_URL=${GPERF_URL} \
-w "${repo_root_dir}" \ -w "${repo_root_dir}" \
--user "$(id -u)":"$(id -g)" \ --user "$(id -u)":"$(id -g)" \
"${container_image}" \ "${container_image}" \