2020-04-21 13:36:27 +00:00
|
|
|
#!/bin/bash
|
2020-04-24 09:27:12 +00:00
|
|
|
|
|
|
|
# shellcheck source=scripts/build_step.inc.sh
|
|
|
|
source "$(dirname "${0}")/build_step.inc.sh"
|
|
|
|
|
2020-04-21 13:36:27 +00:00
|
|
|
set -xe
|
|
|
|
# "docker manifest" requires experimental feature enabled
|
|
|
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
|
|
|
|
2020-04-24 09:12:25 +00:00
|
|
|
cd "$(dirname "${0}")/.."
|
|
|
|
|
2020-04-21 13:36:27 +00:00
|
|
|
# ceph base image used for building multi architecture images
|
2020-06-22 13:54:18 +00:00
|
|
|
build_env="build.env"
|
|
|
|
baseimg=$(awk -F = '/^BASE_IMAGE=/ {print $NF}' "${build_env}")
|
2020-04-21 13:36:27 +00:00
|
|
|
|
|
|
|
# get image digest per architecture
|
|
|
|
# {
|
|
|
|
# "arch": "amd64",
|
2023-11-03 09:17:23 +00:00
|
|
|
# "digest": "sha256:XYZ"
|
2020-04-21 13:36:27 +00:00
|
|
|
# }
|
|
|
|
# {
|
|
|
|
# "arch": "arm64",
|
2023-11-03 09:17:23 +00:00
|
|
|
# "digest": "sha256:ZYX"
|
2020-04-21 13:36:27 +00:00
|
|
|
# }
|
|
|
|
manifests=$(docker manifest inspect "${baseimg}" | jq '.manifests[] | {arch: .platform.architecture, digest: .digest}')
|
|
|
|
# qemu-user-static is to enable an execution of different multi-architecture containers by QEMU
|
|
|
|
# more info at https://github.com/multiarch/qemu-user-static
|
2020-04-24 09:27:12 +00:00
|
|
|
build_step "starting multiarch/qemu-user-static container"
|
2020-04-21 13:36:27 +00:00
|
|
|
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
|
|
# build and push per arch images
|
|
|
|
for ARCH in amd64 arm64; do
|
|
|
|
ifs=$IFS
|
|
|
|
IFS=
|
|
|
|
digest=$(awk -v ARCH=${ARCH} '{if (archfound) {print $NF; exit 0}}; {archfound=($0 ~ "arch.*"ARCH)}' <<<"${manifests}")
|
|
|
|
IFS=$ifs
|
2020-04-22 12:00:34 +00:00
|
|
|
base_img=${baseimg}@${digest}
|
2020-04-24 09:27:12 +00:00
|
|
|
build_step "make image-cephcsi for ${ARCH}"
|
2020-04-22 12:00:34 +00:00
|
|
|
GOARCH=${ARCH} BASE_IMAGE=${base_img} make image-cephcsi
|
2020-04-21 13:36:27 +00:00
|
|
|
done
|