mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-16 06:18:58 +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:
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
|
Reference in New Issue
Block a user