Skip to content

Commit

Permalink
fix: Add M1/ARM support for the test suite (#516)
Browse files Browse the repository at this point in the history
* Add M1/ARM support for the test suite

* Merge ARM/x86 Dockerfiles
  • Loading branch information
fizx authored Feb 27, 2022
1 parent bf4139b commit 7cf5625
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"; }
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ services:
build:
context: .
dockerfile: "protoc.Dockerfile"
args:
- "ARCH=${ARCH:-x86_64}"
volumes:
- ".:/ts-proto"
- "${PWD:-.}:/host"
3 changes: 2 additions & 1 deletion protoc.Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 7cf5625

Please sign in to comment.