Skip to content

Commit

Permalink
refactor: protoc installation (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Freyskeyd authored Apr 11, 2023
1 parent e3e10a4 commit 6211553
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/rust_builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions rust_builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6211553

Please sign in to comment.