mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +00:00
kata-deploy: Split shimv2 build in a separate container.
Instead of install golang in the base container, split the shimv2 build. Signed-off-by: Carlos Venegas <jos.c.venegas.munoz@intel.com>
This commit is contained in:
parent
d46ae3248e
commit
81e6bf6f2c
@ -9,26 +9,14 @@ ENV INSTALL_IN_GOPATH=false
|
|||||||
ADD install_yq.sh /usr/bin/install_yq.sh
|
ADD install_yq.sh /usr/bin/install_yq.sh
|
||||||
|
|
||||||
|
|
||||||
RUN apt-get update
|
# yq installer deps
|
||||||
RUN apt-get install -y curl
|
RUN apt update && apt-get install -y curl sudo
|
||||||
RUN apt-get install -y sudo
|
|
||||||
|
|
||||||
# Install yq
|
# Install yq
|
||||||
RUN install_yq.sh
|
RUN install_yq.sh
|
||||||
|
|
||||||
# Install docker-cli
|
RUN curl -fsSL https://get.docker.com -o get-docker.sh
|
||||||
RUN sudo apt-get -y install \
|
RUN sh get-docker.sh
|
||||||
apt-transport-https \
|
|
||||||
ca-certificates \
|
|
||||||
curl \
|
|
||||||
gnupg \
|
|
||||||
lsb-release
|
|
||||||
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
||||||
RUN echo \
|
|
||||||
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
|
|
||||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install docker-ce-cli -y
|
|
||||||
|
|
||||||
ARG IMG_USER=kata-builder
|
ARG IMG_USER=kata-builder
|
||||||
ARG UID=1000
|
ARG UID=1000
|
||||||
@ -37,11 +25,13 @@ RUN if [ ${IMG_USER} != "root" ]; then groupadd --gid=${GID} ${IMG_USER};fi
|
|||||||
RUN if [ ${IMG_USER} != "root" ]; then adduser ${IMG_USER} --uid=${UID} --gid=${GID};fi
|
RUN if [ ${IMG_USER} != "root" ]; then adduser ${IMG_USER} --uid=${UID} --gid=${GID};fi
|
||||||
RUN sh -c "echo '${IMG_USER} ALL=NOPASSWD: ALL' >> /etc/sudoers"
|
RUN sh -c "echo '${IMG_USER} ALL=NOPASSWD: ALL' >> /etc/sudoers"
|
||||||
|
|
||||||
RUN apt install -y git
|
#FIXME: gcc is required as agent is build out of a container build.
|
||||||
RUN apt install -y make
|
RUN apt-get update && \
|
||||||
|
apt install -y \
|
||||||
# kata deps
|
gcc \
|
||||||
RUN apt install -y golang
|
git \
|
||||||
|
make \
|
||||||
|
xz-utils
|
||||||
|
|
||||||
ENV USER ${IMG_USER}
|
ENV USER ${IMG_USER}
|
||||||
USER ${UID}:${GID}
|
USER ${UID}:${GID}
|
||||||
|
@ -24,6 +24,7 @@ readonly firecracker_builder="${repo_root_dir}/tools/packaging/static-build/fire
|
|||||||
readonly kernel_builder="${repo_root_dir}/tools/packaging/static-build/kernel/build.sh"
|
readonly kernel_builder="${repo_root_dir}/tools/packaging/static-build/kernel/build.sh"
|
||||||
readonly qemu_builder="${repo_root_dir}/tools/packaging/static-build/qemu/build-static-qemu.sh"
|
readonly qemu_builder="${repo_root_dir}/tools/packaging/static-build/qemu/build-static-qemu.sh"
|
||||||
readonly rootfs_builder="${repo_root_dir}/tools/packaging/guest-image/build_image.sh"
|
readonly rootfs_builder="${repo_root_dir}/tools/packaging/guest-image/build_image.sh"
|
||||||
|
readonly shimv2_builder="${repo_root_dir}/tools/packaging/static-build/shim-v2/build.sh"
|
||||||
|
|
||||||
workdir="${WORKDIR:-$PWD}"
|
workdir="${WORKDIR:-$PWD}"
|
||||||
|
|
||||||
@ -137,21 +138,9 @@ install_clh() {
|
|||||||
|
|
||||||
#Install all components that are not assets
|
#Install all components that are not assets
|
||||||
install_shimv2() {
|
install_shimv2() {
|
||||||
pushd "${repo_root_dir}/src/runtime"
|
GO_VERSION="$(yq r ${versions_yaml} languages.golang.meta.newest-version)"
|
||||||
echo "Build"
|
export GO_VERSION
|
||||||
make \
|
DESTDIR="${destdir}" PREFIX="${prefix}" "${shimv2_builder}"
|
||||||
PREFIX="${prefix}" \
|
|
||||||
QEMUCMD="qemu-system-x86_64"
|
|
||||||
echo "Install"
|
|
||||||
make PREFIX="${prefix}" \
|
|
||||||
DESTDIR="${destdir}" \
|
|
||||||
install
|
|
||||||
popd
|
|
||||||
sed -i -e '/^initrd =/d' "${destdir}/${prefix}/share/defaults/${project}/configuration-qemu.toml"
|
|
||||||
sed -i -e '/^initrd =/d' "${destdir}/${prefix}/share/defaults/${project}/configuration-fc.toml"
|
|
||||||
pushd "${destdir}/${prefix}/share/defaults/${project}"
|
|
||||||
ln -sf "configuration-qemu.toml" configuration.toml
|
|
||||||
popd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_kata_version() {
|
get_kata_version() {
|
||||||
|
13
tools/packaging/static-build/shim-v2/Dockerfile
Normal file
13
tools/packaging/static-build/shim-v2/Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Copyright (c) 2021 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
FROM ubuntu
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y make curl sudo gcc
|
||||||
|
|
||||||
|
ADD install_go.sh /usr/bin/install_go.sh
|
||||||
|
ARG GO_VERSION
|
||||||
|
RUN install_go.sh "${GO_VERSION}"
|
||||||
|
ENV PATH=/usr/local/go/bin:${PATH}
|
44
tools/packaging/static-build/shim-v2/build.sh
Executable file
44
tools/packaging/static-build/shim-v2/build.sh
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
readonly repo_root_dir="$(cd "${script_dir}/../../../.." && pwd)"
|
||||||
|
readonly kernel_builder="${repo_root_dir}/tools/packaging/kernel/build-kernel.sh"
|
||||||
|
|
||||||
|
|
||||||
|
GO_VERSION=${GO_VERSION}
|
||||||
|
|
||||||
|
DESTDIR=${DESTDIR:-${PWD}}
|
||||||
|
PREFIX=${PREFIX:-/opt/kata}
|
||||||
|
container_image="shim-v2-builder"
|
||||||
|
|
||||||
|
sudo docker build --build-arg GO_VERSION="${GO_VERSION}" -t "${container_image}" "${script_dir}"
|
||||||
|
|
||||||
|
arch=$(uname -m)
|
||||||
|
if [ ${arch} = "ppc64le" ]; then
|
||||||
|
arch="ppc64"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \
|
||||||
|
-w "${repo_root_dir}/src/runtime" \
|
||||||
|
"${container_image}" \
|
||||||
|
bash -c "make PREFIX=${PREFIX} QEMUCMD=qemu-system-${arch}"
|
||||||
|
|
||||||
|
sudo docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \
|
||||||
|
-w "${repo_root_dir}/src/runtime" \
|
||||||
|
"${container_image}" \
|
||||||
|
bash -c "make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" install"
|
||||||
|
|
||||||
|
sudo sed -i -e '/^initrd =/d' "${DESTDIR}/${PREFIX}/share/defaults/kata-containers/configuration-qemu.toml"
|
||||||
|
sudo sed -i -e '/^initrd =/d' "${DESTDIR}/${PREFIX}/share/defaults/kata-containers/configuration-fc.toml"
|
||||||
|
|
||||||
|
pushd "${DESTDIR}/${PREFIX}/share/defaults/kata-containers"
|
||||||
|
sudo ln -sf "configuration-qemu.toml" configuration.toml
|
||||||
|
popd
|
98
tools/packaging/static-build/shim-v2/install_go.sh
Executable file
98
tools/packaging/static-build/shim-v2/install_go.sh
Executable file
@ -0,0 +1,98 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
tmp_dir=$(mktemp -d -t install-go-tmp.XXXXXXXXXX)
|
||||||
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
script_name="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
force=""
|
||||||
|
|
||||||
|
install_dest="/usr/local/"
|
||||||
|
|
||||||
|
finish() {
|
||||||
|
rm -rf "$tmp_dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echo >&2 "ERROR: $*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
info() {
|
||||||
|
echo "INFO: $*"
|
||||||
|
}
|
||||||
|
|
||||||
|
usage(){
|
||||||
|
exit_code="$1"
|
||||||
|
cat <<EOT
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
${script_name} [options]
|
||||||
|
|
||||||
|
Example:
|
||||||
|
${script_name}
|
||||||
|
|
||||||
|
Options
|
||||||
|
-d <path> : destination path, path where go will be installed.
|
||||||
|
EOT
|
||||||
|
|
||||||
|
exit "$exit_code"
|
||||||
|
}
|
||||||
|
|
||||||
|
trap finish EXIT
|
||||||
|
|
||||||
|
pushd "${tmp_dir}"
|
||||||
|
|
||||||
|
while getopts "d:fhp" opt
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
d) install_dest="${OPTARG}" ;;
|
||||||
|
f) force="true" ;;
|
||||||
|
h) usage 0 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $(( $OPTIND - 1 ))
|
||||||
|
|
||||||
|
|
||||||
|
go_version=${1:-}
|
||||||
|
|
||||||
|
if [ -z "$go_version" ];then
|
||||||
|
echo "Missing go"
|
||||||
|
usage 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v go; then
|
||||||
|
[[ "$(go version)" == *"go${go_version}"* ]] && \
|
||||||
|
info "Go ${go_version} already installed" && \
|
||||||
|
exit
|
||||||
|
if [ "${force}" = "true" ]; then
|
||||||
|
info "removing $(go version)"
|
||||||
|
sudo rm -rf "${install_dest}/go"
|
||||||
|
else
|
||||||
|
die "$(go version) is installed, use -f or remove it before install go ${go_version}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$(uname -m)" in
|
||||||
|
aarch64) goarch="arm64";;
|
||||||
|
ppc64le) goarch="ppc64le";;
|
||||||
|
x86_64) goarch="amd64";;
|
||||||
|
s390x) goarch="s390x";;
|
||||||
|
*) echo "unsupported architecture: $(uname -m)"; exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
info "Download go version ${go_version}"
|
||||||
|
kernel_name=$(uname -s)
|
||||||
|
curl -OL "https://storage.googleapis.com/golang/go${go_version}.${kernel_name,,}-${goarch}.tar.gz"
|
||||||
|
info "Install go"
|
||||||
|
mkdir -p "${install_dest}"
|
||||||
|
sudo tar -C "${install_dest}" -xzf "go${go_version}.${kernel_name,,}-${goarch}.tar.gz"
|
||||||
|
popd
|
Loading…
Reference in New Issue
Block a user