From 592e4bf30ee1dab56fb440bd95442f842a925613 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Pelayo Date: Fri, 4 Mar 2022 12:31:07 +0100 Subject: [PATCH 1/2] Pack containers during GitHub CI release.sh These .tar.gzs can be later used by common non-podman capable builders (copr) to create rpms with the container images. Signed-off-by: Miguel Angel Ajo --- .github/workflows/release.yaml | 2 +- Makefile | 8 +++++ packaging/images/components/archive.sh | 43 ++++++++++++++++++++++++++ scripts/release.sh | 3 ++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100755 packaging/images/components/archive.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 38fe82af3b..0718c1e447 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,7 +20,7 @@ jobs: password: ${{ secrets.REGISTRY_PASSWORD }} - name: Install required packages - run: sudo apt-get update && sudo apt install build-essential qemu-user qemu-user-static + run: sudo apt-get update && sudo apt install build-essential qemu-user qemu-user-static podman - name: Checkout source uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index 9d541fed82..ecd0939024 100644 --- a/Makefile +++ b/Makefile @@ -218,6 +218,14 @@ build-containerized-all-in-one-iptables-arm64: +$(MAKE) _build_containerized_aio ARCH=arm64 IPTABLES=iptables .PHONY: build-containerized-all-in-one-iptables-arm64 +############################### +# container image packaging # +############################### + +image-tars: + sudo ./packaging/images/components/archive.sh +.PHONY: image-tars + ############################### # dev targets # ############################### diff --git a/packaging/images/components/archive.sh b/packaging/images/components/archive.sh new file mode 100755 index 0000000000..91f106c339 --- /dev/null +++ b/packaging/images/components/archive.sh @@ -0,0 +1,43 @@ +#!/bin/bash +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +get="${SCRIPT_DIR}/../../../pkg/release/get.sh" + +ARCHITECTURES=${ARCHITECTURES:-"arm64 amd64"} +BASE_VERSION=${BASE_VERSION:-$("${get}" base)} +OUTPUT_DIR=${OUTPUT_DIR:-$(pwd)/archive} + +TMP_DIR=$(mktemp -d) + +mkdir -p "${OUTPUT_DIR}" +chmod a+rwx "${OUTPUT_DIR}" + +for arch in $ARCHITECTURES; do + images=$("${get}" images $arch) + storage="${TMP_DIR}/${arch}/containers" + mkdir -p "${storage}" + echo "Pulling images for architecture ${arch} ===================" + for image in $images; do + echo pulling $image @$arch + # some imported images are armhfp instead of arm + podman pull --arch $arch --root "${storage}" "${image}" + if [ $? -ne 0 ]; then + if [ "${arch}" == "arm" ]; then + echo "Fallback arm -> armhfp" + podman pull --arch armhfp --root "${TMP_DIR}/${arch}" "${image}" || exit 1 + else + echo "Couldn't pull image ${image} for ${arch}" + exit 1 + fi + fi + done + + echo "" + echo "Packing tarball for architecture ${arch} ==================" + pushd ${storage} + output_file="${OUTPUT_DIR}/microshift-containers-${BASE_VERSION}-${arch}.tar.bz2" + echo " > ${output_file}" + tar cfj "${OUTPUT_DIR}/microshift-containers-${BASE_VERSION}-${arch}.tar.bz2" . + chmod a+rw "${OUTPUT_DIR}/microshift-containers-${BASE_VERSION}-${arch}.tar.bz2" + popd + rm -rf ${storage} +done diff --git a/scripts/release.sh b/scripts/release.sh index ab53f3ee3d..f93560b511 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -304,6 +304,9 @@ if [ $NIGHTLY -eq 1 ]; then exit 0 fi +# create container tar.gzs for the consumed container images for non-nightly releases +ARCHITECTURES="amd64 arm64" OUTPUT_DIR="${STAGE_DIR}" sudo -E "${ROOT}/packaging/image/components/archive.sh" || exit 1 + # publish binaries UPLOAD_URL="$(git_create_release "$API_DATA" "$TOKEN")" || exit 1 git_post_artifacts "$STAGE_DIR" "$UPLOAD_URL" "$TOKEN" || exit 1 From 65c82ad308ac2fd345c47f04bc0bc8d93c93e052 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Mon, 7 Mar 2022 19:24:49 +0100 Subject: [PATCH 2/2] Address comments for Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ecd0939024..0edff7d298 100644 --- a/Makefile +++ b/Makefile @@ -222,7 +222,7 @@ build-containerized-all-in-one-iptables-arm64: # container image packaging # ############################### -image-tars: +tar-ocp-containers: sudo ./packaging/images/components/archive.sh .PHONY: image-tars