From 7cf56251726d149eebd015367476f36e4edb48aa Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Sun, 27 Feb 2022 12:42:31 -0800 Subject: [PATCH] fix: Add M1/ARM support for the test suite (#516) * Add M1/ARM support for the test suite * Merge ARM/x86 Dockerfiles --- aliases.sh | 8 +++++++- docker-compose.yml | 2 ++ protoc.Dockerfile | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/aliases.sh b/aliases.sh index 7808edc1d..f77b9f3c5 100644 --- a/aliases.sh +++ b/aliases.sh @@ -3,7 +3,13 @@ PROJECT_ROOT=$(realpath $(dirname "$BASH_SOURCE")) PROJECT_ROOT_DOCKER="//ts-proto" # double slash to support git bash on windows # Alias docker-compose to make it usable from anywhere. -function _docker-compose() { docker-compose -f $PROJECT_ROOT/docker-compose.yml "$@"; } +function _docker-compose() { + if [ uname -a | grep arm64 ] + then + ARCH=aarch_64 + fi + docker-compose -f $PROJECT_ROOT/docker-compose.yml "$@"; +} # Dockerized version of protoc. function protoc() { _docker-compose run --rm -w //host --entrypoint protoc -- protoc "$@"; } diff --git a/docker-compose.yml b/docker-compose.yml index 33d1da732..20a367133 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,8 @@ services: build: context: . dockerfile: "protoc.Dockerfile" + args: + - "ARCH=${ARCH:-x86_64}" volumes: - ".:/ts-proto" - "${PWD:-.}:/host" diff --git a/protoc.Dockerfile b/protoc.Dockerfile index ef3b50c6f..08812dd47 100644 --- a/protoc.Dockerfile +++ b/protoc.Dockerfile @@ -1,10 +1,11 @@ # Docker image for protoc FROM node:17-alpine3.14 ARG PROTOC_VERSION="3.19.1" +ARG ARCH="x86_64" RUN apk add bash RUN apk add gcompat -ADD "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip" protoc.zip +ADD "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-$ARCH.zip" protoc.zip RUN mkdir /usr/local/lib/protoc && unzip protoc.zip -d /usr/local/lib/protoc && rm protoc.zip RUN ln -s /usr/local/lib/protoc/bin/protoc /usr/local/bin/protoc