Select protoc based on target arch
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.
@@ -13,25 +13,31 @@ RUN apt-get update && \
libpq-dev \
libssl-dev \
pkg-config \
- protobuf-compiler \
libzmq3-dev \
libsqlite3-dev \
sqlite3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
-
-RUN curl https://sh.rustup.rs -sSf > /usr/bin/rustup-init && \
- chmod +x /usr/bin/rustup-init && \
- rustup-init -y
-
+ENV PATH=$PATH:/root/.cargo/bin
+
+# Install Rust
+RUN curl https://sh.rustup.rs -sSf > /usr/bin/rustup-init \
+ && chmod +x /usr/bin/rustup-init \
+ && rustup-init -y \
+# Install protoc
+ && 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
-RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
-
-ENV PATH=$PATH:/root/.cargo/bin \
- CARGO_INCREMENTAL=0
+ && curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
-RUN rustup component add clippy && \
- rustup component add rustfmt
+ENV CARGO_INCREMENTAL=0
WORKDIR /project/transact
