Integrate upstream Aarch64 changes (#332)

* Integrate upstream Aarch64 changes

* Update Makefile to support parameterized builds.
diff --git a/Dockerfile b/Dockerfile
index b87b0dd..47dd8e1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -24,6 +24,9 @@
 
 FROM alpine:3.9
 
+# Busybox's ash shell supports pipefail, which is useful for tarballs
+SHELL [ "/bin/ash", "-o", "pipefail", "-c"]
+
 # install dependencies
 RUN apk update && \
     apk add \
@@ -86,18 +89,33 @@
      && tar -zxf ./openresty-${OPENRESTY_VERSION}.tar.gz \
      && tar -zxf ./pcre-${PCRE_VERSION}.tar.gz \
      && cd /tmp/api-gateway/openresty-${OPENRESTY_VERSION} \
-
-     && if [ x`uname -m` = xs390x ]; then \
+     && case "$(uname -m)" in \
+        aarch64) \
+          luajitdir="" \
+          pcrejit="--with-pcre-jit" \
+          ; echo " ... Patching ngx_lua and LuaJIT modules for ARM64 ... " \
+          && rm -rf ./bundle/ngx_lua-* \
+          && curl -k -L https://github.com/openresty/lua-nginx-module/archive/v0.10.14rc3.tar.gz \
+            | tar -zxf - -C ./bundle \
+          && mv ./bundle/lua-nginx-module-0.10.14rc3 ./bundle/ngx_lua-0.10.14rc3 \
+          && rm -rf ./bundle/LuaJIT-* \
+          && curl -k -L https://github.com/openresty/luajit2/archive/v2.1-20181029.tar.gz \
+            | tar -zxf - -C ./bundle \
+          && mv ./bundle/luajit2-2.1-20181029 ./bundle/LuaJIT-2.2.1-20181029 \
+          ;; \
+        s390x) \
           luajitdir="=/usr/local/" \
-	  pcrejit="" \
-        ; elif [ x`uname -m` = xppc64le ]; then \
+          pcrejit="" \
+          ;; \
+        ppc64le) \
           luajitdir="=/usr/local/" \
           pcrejit="--with-pcre-jit" \
-        ; else \
-	  luajitdir="" \
-	  pcrejit="--with-pcre-jit" \
-	; fi \
-
+          ;; \
+        *) \
+          luajitdir="" \
+          pcrejit="--with-pcre-jit" \
+          ;; \
+      esac \
      && echo "        - building debugging version of the api-gateway ... " \
      && ./configure \
             --prefix=${_exec_prefix}/api-gateway \
diff --git a/Makefile b/Makefile
index d4eee3b..7da0c67 100644
--- a/Makefile
+++ b/Makefile
@@ -15,15 +15,24 @@
 # limitations under the License.
 #
 
-DOCKER_TAG ?= snapshot-`date +'%Y%m%d-%H%M'`
-DOCKER_REGISTRY ?= ''
+#
+#  TODO:  Use 'latest'; override with "latest-$(uname -m)" for multiarch
+#
+#DOCKER_TAG ?= snapshot-`date +'%Y%m%d-%H%M'`
+
+OPENWHISK_TARGET_REGISTRY ?= docker.io
+OPENWHISK_TARGET_PREFIX ?= openwhisk
+OPENWHISK_TARGET_TAG ?= latest
+
+RUNTIME := ${OPENWHISK_TARGET_REGISTRY}/${OPENWHISK_TARGET_PREFIX}/apigateway:${OPENWHISK_TARGET_TAG}
+PROFILING := ${OPENWHISK_TARGET_REGISTRY}/${OPENWHISK_TARGET_PREFIX}/apigateway-profiling:${OPENWHISK_TARGET_TAG}
 
 docker:
-	docker build -t openwhisk/apigateway .
+	docker build -t ${RUNTIME} .
 
 .PHONY: docker-ssh
 docker-ssh:
-	docker run -ti --entrypoint='bash' openwhisk/apigateway:latest
+	docker run -ti --entrypoint='bash' ${RUNTIME}
 
 .PHONY: test-build
 test-build:
@@ -32,7 +41,7 @@
 .PHONY: profile-build
 profile-build:
 	./build_profiling.sh
-	docker build -t openwhisk/apigateway-profiling -f Dockerfile.profiling .
+	docker build -t ${PROFILING} -f Dockerfile.profiling .
 
 .PHONY: profile-run
 profile-run: profile-build
@@ -47,7 +56,7 @@
 		-e CACHE_SIZE=2048 \
 		-e CACHE_TTL=180 \
 		-e OPTIMIZE=1 \
-		-d openwhisk/apigateway-profiling:latest
+		-d ${PROFILING}
 
 .PHONY: test-run
 test-run:
@@ -64,7 +73,7 @@
 		-e TOKEN_GITHUB_URL=https://api.github.com/user \
 		-e APPID_PKURL=https://appid-oauth.ng.bluemix.net/oauth/v3/ \
 		-e LD_LIBRARY_PATH=/usr/local/lib \
-		openwhisk/apigateway:latest
+		${TARGET}
 
 .PHONY: docker-debug
 docker-debug:
@@ -76,7 +85,7 @@
 			-p 80:80 -p 5000:5000 \
 			-e "LOG_LEVEL=info" -e "DEBUG=true" \
 			-v ${HOME}/tmp/apiplatform/apigateway/:/etc/api-gateway \
-			openwhisk/apigateway:latest ${DOCKER_ARGS}
+			${TARGET}
 
 .PHONY: docker-reload
 docker-reload: