From 41b452849ce36c586e4f93c85f68501293fb810e Mon Sep 17 00:00:00 2001 From: Radoslav Dimitrov Date: Mon, 3 Dec 2018 00:20:34 +0200 Subject: [PATCH] Add a consistent ARM64 image build process Signed-off-by: Radoslav Dimitrov --- Makefile | 10 +++++++++- contrib/publish-armhf.sh | 15 ++++++++++++--- gateway/build.sh | 5 +++++ gateway/push.sh | 4 ++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 98bcd1c7..002e6e82 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ -.PHONY: build build-gateway test-ci +.PHONY: build build-gateway test-ci ci-armhf-build ci-armhf-push ci-arm64-build ci-arm64-push TAG?=latest build: ./build.sh + build-gateway: (cd gateway; ./build.sh latest-dev) + test-ci: ./contrib/ci.sh @@ -13,3 +15,9 @@ ci-armhf-build: ci-armhf-push: (cd gateway; ./push.sh $(TAG)) + +ci-arm64-build: + (cd gateway; ./build.sh $(TAG)) + +ci-arm64-push: + (cd gateway; ./push.sh $(TAG)) diff --git a/contrib/publish-armhf.sh b/contrib/publish-armhf.sh index e3a66c0f..72802446 100755 --- a/contrib/publish-armhf.sh +++ b/contrib/publish-armhf.sh @@ -2,6 +2,7 @@ declare -a repos=("openfaas-incubator/openfaas-operator" "openfaas-incubator/faas-idler" "openfaas/faas" "openfaas/faas-swarm" "openfaas/nats-queue-worker" "openfaas/faas-netes" "openfaas/faas-cli") HERE=`pwd` +ARCH=$(uname -m) #if [ ! -z "$CACHED" ]; then rm -rf staging || : @@ -24,6 +25,14 @@ get_repo_name() { fi } +if [ "$ARCH" = "armv7l" ] ; then + ARM_VERSION="armhf" +elif [ "$ARCH" = "aarch64" ] ; then + ARM_VERSION="arm64" +fi + +echo "Target architecture: ${ARM_VERSION}" + for i in "${repos[@]}" do cd $HERE @@ -36,11 +45,11 @@ do echo "Latest release: $TAG" REPOSITORY=$(get_repo_name $i) - TAG_PRESENT=$(curl -s "https://hub.docker.com/v2/repositories/${REPOSITORY}/tags/${TAG}-armhf/" | grep -Po '"detail": *"[^"]*"' | grep -o 'Not found') + TAG_PRESENT=$(curl -s "https://hub.docker.com/v2/repositories/${REPOSITORY}/tags/${TAG}-${ARM_VERSION}/" | grep -Po '"detail": *"[^"]*"' | grep -o 'Not found') if [ "$TAG_PRESENT" = "Not found" ]; then - make ci-armhf-build ci-armhf-push + make ci-${ARM_VERSION}-build ci-${ARM_VERSION}-push else - echo "Image is already present: ${REPOSITORY}:${TAG}-armhf" + echo "Image is already present: ${REPOSITORY}:${TAG}-${ARM_VERSION}" fi done diff --git a/gateway/build.sh b/gateway/build.sh index 763879e9..689e1738 100755 --- a/gateway/build.sh +++ b/gateway/build.sh @@ -9,6 +9,9 @@ export eTAG="latest-dev" if [ "$arch" = "armv7l" ] ; then dockerfile="Dockerfile.armhf" eTAG="latest-armhf-dev" +elif [ "$arch" = "aarch64" ] ; then + dockerfile="Dockerfile.arm64" + eTAG="latest-arm64-dev" fi echo "$1" @@ -16,6 +19,8 @@ if [ "$1" ] ; then eTAG=$1 if [ "$arch" = "armv7l" ] ; then eTAG="$1-armhf" + elif [ "$arch" = "aarch64" ] ; then + eTAG="$1-arm64" fi fi diff --git a/gateway/push.sh b/gateway/push.sh index 5f9bb87d..119a11b8 100755 --- a/gateway/push.sh +++ b/gateway/push.sh @@ -7,6 +7,8 @@ export eTAG="latest-dev" if [ "$arch" = "armv7l" ] ; then eTAG="latest-armhf-dev" +elif [ "$arch" = "aarch64" ] ; then + eTAG="latest-arm64-dev" fi echo "$1" @@ -14,6 +16,8 @@ if [ "$1" ] ; then eTAG=$1 if [ "$arch" = "armv7l" ] ; then eTAG="$1-armhf" + elif [ "$arch" = "aarch64" ] ; then + eTAG="$1-arm64" fi fi