Select protoc based on target arch in crates dockerfile
This change selects the protoc compiler for protobuf based on the target
architecture (x86_64 vs arm64). This allows for native usage on Apple M1
silicon, as well as other arm64 environments.
@@ -43,14 +43,22 @@ RUN apt-get update && \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
+# Install Rust
RUN curl https://sh.rustup.rs -sSf > /usr/bin/rustup-init \
&& chmod +x /usr/bin/rustup-init \
- && rustup-init -y
-
+ && rustup-init -y \
# Install protoc
-RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip \
- && unzip -o protoc-3.7.1-linux-x86_64.zip -d /usr/local \
- && rm protoc-3.7.1-linux-x86_64.zip
+ && TARGET_ARCH=$(dpkg --print-architecture) \
+ && if [[ $TARGET_ARCH == "arm64" ]]; then \
+ PROTOC_ARCH="aarch_64"; \
+ elif [[ $TARGET_ARCH == "amd64" ]]; then \
+ PROTOC_ARCH="x86_64"; \
+ fi \
+ && curl -OLsS https://github.com/google/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-$PROTOC_ARCH.zip \
+ && unzip -o protoc-3.7.1-linux-$PROTOC_ARCH.zip -d /usr/local \
+ && rm protoc-3.7.1-linux-$PROTOC_ARCH.zip \
+# Install just
+ && curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
ENV PATH=$PATH:/root/.cargo/bin
