From ecd8197ab1130a0292b693ec33342ee7901a08e0 Mon Sep 17 00:00:00 2001 From: ChengyuZhu6 Date: Mon, 11 Sep 2023 18:34:23 +0800 Subject: [PATCH] .ci: install nydus snapshotter Signed-off-by: ChengyuZhu6 --- .ci/install_nydus_snapshotter.sh | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .ci/install_nydus_snapshotter.sh diff --git a/.ci/install_nydus_snapshotter.sh b/.ci/install_nydus_snapshotter.sh new file mode 100644 index 000000000..06a2f9b8c --- /dev/null +++ b/.ci/install_nydus_snapshotter.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Copyright (c) 2023 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -o errexit +set -o nounset +set -o pipefail +set -o errtrace + +cidir=$(dirname "$0") +source "${cidir}/lib.sh" + +BUILD_SNAPSHOTTER=${BUILD_SNAPSHOTTER:-false} + +target_dir="/opt/confidential-containers" + +nydus_snapshotter_repo=${nydus_snapshotter_repo:-"github.com/containerd/nydus-snapshotter"} +nydus_snapshotter_repo_git="https://${nydus_snapshotter_repo}.git" +nydus_snapshotter_version=${nydus_snapshotter_version:-"v0.10.0"} +nydus_snapshotter_repo_dir="${GOPATH}/src/${nydus_snapshotter_repo}" +nydus_snapshotter_binary_target_dir="$target_dir/bin" +nydus_snapshotter_config_target_dir="$target_dir/share/nydus-snapshotter" + +nydus_repo=${nydus_repo:-"https://github.com/dragonflyoss/image-service"} +nydus_version=${nydus_version:-"v2.2.3"} + +clone_nydus_snapshotter_repo() { + add_repo_to_git_safe_directory "${nydus_snapshotter_repo_dir}" + + if [ ! -d "${nydus_snapshotter_repo_dir}" ]; then + mkdir -p "${nydus_snapshotter_repo_dir}" + git clone ${nydus_snapshotter_repo_git} "${nydus_snapshotter_repo_dir}" || true + pushd "${nydus_snapshotter_repo_dir}" + git checkout "${nydus_snapshotter_version}" + popd + fi +} + +build_nydus_snapshotter() { + pushd "${nydus_snapshotter_repo_dir}" + sudo -E PATH=$PATH make + sudo install -D -m 755 "bin/containerd-nydus-grpc" "$nydus_snapshotter_binary_target_dir/containerd-nydus-grpc" + sudo install -D -m 755 "bin/nydus-overlayfs" "$nydus_snapshotter_binary_target_dir/nydus-overlayfs" + sudo ln -s "$nydus_snapshotter_binary_target_dir/nydus-overlayfs" "/usr/bin/nydus-overlayfs" + rm -rf "./bin" + popd >/dev/null +} + +download_nydus_snapshotter_config() { + if [ ! -d "$nydus_snapshotter_config_target_dir" ]; then + mkdir -p "$nydus_snapshotter_config_target_dir" + fi + sudo curl -L https://raw.githubusercontent.com/containerd/nydus-snapshotter/main/misc/snapshotter/config-coco-guest-pulling.toml -o "$nydus_snapshotter_config_target_dir/config-coco-guest-pulling.toml" + sudo curl -L https://raw.githubusercontent.com/containerd/nydus-snapshotter/main/misc/snapshotter/config-coco-host-sharing.toml -o "$nydus_snapshotter_config_target_dir/config-coco-host-sharing.toml" + sudo chmod 644 "$nydus_snapshotter_config_target_dir/*" +}