From 537bffe16ea2d4188589a4d707e9364850177467 Mon Sep 17 00:00:00 2001 From: Dan Voiculeasa Date: Tue, 14 Jun 2022 23:23:08 +0300 Subject: [PATCH] Add support for building armada image Follow-up to https://review.opendev.org/c/starlingx/integ/+/845752. As explained in the mentioned commit we need to build the armada container image using the sources provided there. Add support for that. Partial-Bug: 1978409 Signed-off-by: Dan Voiculeasa Change-Id: I26e8117272a6925ea429be10be91ce20f6b71c8b --- distroless_stable_docker_images.inc | 1 + .../armada-image.stable_docker_image | 7 +++ .../armada/distroless/build-armada-image.sh | 54 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 kubernetes/armada/distroless/armada-image.stable_docker_image create mode 100644 kubernetes/armada/distroless/build-armada-image.sh diff --git a/distroless_stable_docker_images.inc b/distroless_stable_docker_images.inc index 60f91c5dd..d89786767 100644 --- a/distroless_stable_docker_images.inc +++ b/distroless_stable_docker_images.inc @@ -1,2 +1,3 @@ +kubernetes/armada kubernetes/plugins/intel-device-plugin kubernetes/plugins/sriov-network-device-plugin diff --git a/kubernetes/armada/distroless/armada-image.stable_docker_image b/kubernetes/armada/distroless/armada-image.stable_docker_image new file mode 100644 index 000000000..f1d9a674b --- /dev/null +++ b/kubernetes/armada/distroless/armada-image.stable_docker_image @@ -0,0 +1,7 @@ +BUILDER=script +LABEL=armada-image +SOURCE_REPO=https://github.com/airshipit/armada +SOURCE_REF=ddbdd7256c20f138737f6cbd772312f7a19f58b8 +COMMAND=bash +SCRIPT=build-armada-image.sh +ARGS="armada-image" diff --git a/kubernetes/armada/distroless/build-armada-image.sh b/kubernetes/armada/distroless/build-armada-image.sh new file mode 100644 index 000000000..15b0dbc6f --- /dev/null +++ b/kubernetes/armada/distroless/build-armada-image.sh @@ -0,0 +1,54 @@ +#!/bin/bash +################################################################################ +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +################################################################################ + +PROJECT=$1 +IMAGE_TAG=$2 + +if [ -z "${IMAGE_TAG}" ]; then + echo "image tag must be specified. build ${PROJECT} Aborting..." >&2 + exit 1 +fi + +# Copy patches from: +# https://opendev.org/starlingx/integ/src/branch/master/kubernetes/armada/debian/deb_folder/patches +tmp_dir=$(mktemp -d -t armada-XXXXXXXXXX --tmpdir=/tmp) +pushd ${tmp_dir} +git clone https://opendev.org/starlingx/integ/ +if [ $? -ne 0 ]; then + echo "Failed to clone patches for ${PROJECT}. Aborting..." >&2 + exit 1 +fi +popd +cp -r ${tmp_dir}/integ/kubernetes/armada/debian/deb_folder/patches . +rm -rf ${tmp_dir} + +# Apply patches +pushd patches +cat series | xargs -n 1 git am +if [ $? -ne 0 ]; then + echo "Failed to apply patches for ${PROJECT}. Aborting..." >&2 + exit 1 +fi +popd + +# Use Makefile to build images +make images +if [ $? -ne 0 ]; then + echo "Failed to make ${PROJECT} image. Aborting..." >&2 + exit 1 +fi + +RETVAL=0 +docker tag quay.io/airshipit/armada:latest-ubuntu_bionic "${IMAGE_TAG}" +if [ $? -ne 0 ]; then + echo "Failed to tag ${PROJECT} with ${IMAGE_TAG}. Aborting..." >&2 + RETVAL=1 +fi + +docker rmi quay.io/airshipit/armada:latest-ubuntu_bionic +exit ${RETVAL}