From 621155317eeeca4f947cd4850042494394864224 Mon Sep 17 00:00:00 2001 From: Simon Paitrault Date: Tue, 11 Apr 2023 15:31:29 +0200 Subject: [PATCH] refactor: protoc installation (#23) --- .github/workflows/rust_builder.yml | 2 -- rust_builder/Dockerfile | 17 +++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rust_builder.yml b/.github/workflows/rust_builder.yml index fe41d2f..6facb38 100644 --- a/.github/workflows/rust_builder.yml +++ b/.github/workflows/rust_builder.yml @@ -10,7 +10,6 @@ on: env: registry: ghcr.io - protobuf_compiler: https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-linux-x86_64.zip jobs: build-and-push-image: @@ -65,7 +64,6 @@ jobs: build-args: | TOOLCHAIN_VERSION=${{ matrix.toolchain_version }} DEBIAN_SUITE=${{ matrix.debian_suite }} - PROTOBUF_COMPILER=${{ env.protobuf_compiler }} context: ./rust_builder/ push: true platforms: linux/amd64,linux/arm64 diff --git a/rust_builder/Dockerfile b/rust_builder/Dockerfile index 3780ff6..4ec41e4 100644 --- a/rust_builder/Dockerfile +++ b/rust_builder/Dockerfile @@ -2,19 +2,24 @@ ARG DEBIAN_SUITE FROM rust:${DEBIAN_SUITE} RUN apt update && \ - apt install -y clang cmake wget unzip - -ARG PROTOBUF_COMPILER -RUN wget ${PROTOBUF_COMPILER} && \ - unzip ${PROTOBUF_COMPILER##*/} -d /usr/local && \ - rm ${PROTOBUF_COMPILER##*/} + apt install -y clang cmake ARG TOOLCHAIN_VERSION + +ARG PROTOC_VERSION=22.2 + ENV CARGO_NET_GIT_FETCH_WITH_CLI=true ENV CARGO_TERM_COLOR=always ENV RUSTFLAGS=-Dwarnings ENV RUST_BACKTRACE=1 +RUN ARCHITECTURE=$(uname -m | sed -e "s/arm64/arm_64/g" | sed -e "s/aarch64/aarch_64/g") \ + && curl -LOs "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-$ARCHITECTURE.zip" \ + && unzip -o "protoc-${PROTOC_VERSION}-linux-$ARCHITECTURE.zip" -d /usr/local bin/protoc \ + && unzip -o "protoc-${PROTOC_VERSION}-linux-$ARCHITECTURE.zip" -d /usr/local 'include/*' \ + && chmod +x "/usr/local/bin/protoc" \ + && rm "protoc-${PROTOC_VERSION}-linux-$ARCHITECTURE.zip" + RUN rustup toolchain install ${TOOLCHAIN_VERSION} && \ rustup default ${TOOLCHAIN_VERSION} && \ cargo install sccache --locked