Support Arm64 image

Update CI merge job to build and push Arm64 image to
quay.io/cephcsi/cephcsi:version-arm64.

Add CI PR job running on Travis Arm64 nodes to make sure cephcsi
compiles successfully on Arm64.

No CI test job is availabe for Arm64 now due to below issues
- k8s-csi sidecar images for Arm64 are not available
- Travis Arm64 CI job runs inside unprivileged LXD which blocks
  launching minikube test environment

Signed-off-by: Yibo Cai <yibo.cai@arm.com>
This commit is contained in:
Yibo Cai
2019-11-07 17:55:12 +08:00
committed by mergify[bot]
parent 543360ee00
commit 4b8b52e0de
6 changed files with 74 additions and 9 deletions

View File

@ -33,6 +33,42 @@ push_helm_charts() {
}
# Build and push images. Steps as below:
# 1. get base image from original Dockerfile (FROM ceph/ceph:v14.2)
# 2. parse manifest to get image digest per arch (sha256:XXX, sha256:YYY)
# 3. patch Dockerfile with amd64 base image (FROM ceph/ceph:v14.2@sha256:XXX)
# 4. build and push amd64 image
# 5. patch Dockerfile with arm64 base image (FROM ceph/ceph:v14.2@sha256:YYY)
# 6. build and push arm64 image
build_push_images() {
# "docker manifest" requires experimental feature enabled
export DOCKER_CLI_EXPERIMENTAL=enabled
# get baseimg (ceph/ceph:tag)
dockerfile="deploy/cephcsi/image/Dockerfile"
baseimg=$(awk '/^FROM/ {print $NF}' "${dockerfile}")
# get image digest per architecture
# {
# "arch": "amd64",
# "digest": "sha256:XXX"
# }
# {
# "arch": "arm64",
# "digest": "sha256:YYY"
# }
manifests=$("${CONTAINER_CMD:-docker}" manifest inspect "${baseimg}" | jq '.manifests[] | {arch: .platform.architecture, digest: .digest}')
# 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
sed -i "s|\(^FROM.*\)${baseimg}.*$|\1${baseimg}@${digest}|" "${dockerfile}"
GOARCH=${ARCH} make push-image-cephcsi
done
}
if [ "${TRAVIS_BRANCH}" == 'master' ]; then
export ENV_CSI_IMAGE_VERSION='canary'
else
@ -42,10 +78,11 @@ fi
if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
"${CONTAINER_CMD:-docker}" login -u "${QUAY_IO_USERNAME}" -p "${QUAY_IO_PASSWORD}" quay.io
make push-image-cephcsi
set -xe
build_push_images
mkdir -p tmp
pushd tmp >/dev/null