-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci: Slim down CI builder The CI builder image is downloaded many hundreds of times per day. The larger it is, the longer it takes for each CI executor to spin up which increases overall CI runtime. It also causes a significant amount of bandwidth costs from GCP Artifact Registry. This PR reduces the size of CI builder by moving the Rust toolchain to a dedicated builder image which will only be used with the jobs that require it. The Rust toolchain accounts for more than 50% of the size of the builder image. * add binutils * fix path * Update SVM * have to source bash first * bad copy * add back elf tools
- Loading branch information
Showing
5 changed files
with
38 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ on: | |
type: choice | ||
options: | ||
- ci-builder | ||
- ci-builder-rust | ||
- indexer | ||
- op-heartbeat | ||
- chain-mon | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,15 +28,18 @@ COPY ./versions.json ./versions.json | |
COPY ./ops/scripts/install-foundry.sh ./install-foundry.sh | ||
|
||
RUN curl -L https://foundry.paradigm.xyz | bash | ||
RUN source $HOME/.profile && ./install-foundry.sh | ||
RUN source $HOME/.profile && \ | ||
./install-foundry.sh && \ | ||
cargo install svm-rs | ||
|
||
RUN strip /root/.foundry/bin/forge && \ | ||
strip /root/.foundry/bin/cast && \ | ||
strip /root/.foundry/bin/anvil | ||
strip /root/.foundry/bin/anvil && \ | ||
strip /root/.cargo/bin/svm | ||
|
||
FROM --platform=linux/amd64 debian:bullseye-slim as go-build | ||
|
||
RUN apt-get update && apt-get install -y curl ca-certificates jq | ||
RUN apt-get update && apt-get install -y curl ca-certificates jq binutils | ||
|
||
ENV GO_VERSION=1.21.1 | ||
|
||
|
@@ -56,16 +59,20 @@ RUN go install gotest.tools/gotestsum@latest | |
RUN go install github.com/vektra/mockery/[email protected] | ||
RUN go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
|
||
FROM --platform=linux/amd64 debian:bullseye-slim | ||
# Strip binaries to reduce size | ||
RUN strip /go/bin/gotestsum && \ | ||
strip /go/bin/mockery && \ | ||
strip /go/bin/golangci-lint && \ | ||
strip /go/bin/abigen && \ | ||
strip /go/bin/geth | ||
|
||
FROM --platform=linux/amd64 debian:bullseye-slim as base-builder | ||
|
||
ENV GOPATH=/go | ||
ENV PATH=/usr/local/go/bin:$GOPATH/bin:$PATH | ||
ENV PATH=/root/.cargo/bin:$PATH | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Create rust directories for copying the installation into | ||
RUN mkdir /root/.cargo && mkdir /root/.cargo/bin && mkdir /root/.rustup | ||
|
||
# copy the go installation, but not the module cache (cache will get stale, and would add a lot of weight) | ||
COPY --from=go-build /usr/local/go /usr/local/go | ||
|
||
|
@@ -76,14 +83,11 @@ COPY --from=go-build /go/bin/golangci-lint /go/bin/golangci-lint | |
COPY --from=go-build /go/bin/abigen /usr/local/bin/abigen | ||
COPY --from=go-build /go/bin/geth /usr/local/bin/geth | ||
|
||
# copy the rust installation, alongside the installed toolchains | ||
COPY --from=rust-build /root/.cargo/bin /root/.cargo/bin | ||
COPY --from=rust-build /root/.rustup /root/.rustup | ||
|
||
# copy tools | ||
COPY --from=rust-build /root/.foundry/bin/forge /usr/local/bin/forge | ||
COPY --from=rust-build /root/.foundry/bin/cast /usr/local/bin/cast | ||
COPY --from=rust-build /root/.foundry/bin/anvil /usr/local/bin/anvil | ||
COPY --from=rust-build /root/.cargo/bin/svm /usr/local/bin/svm | ||
|
||
COPY .nvmrc .nvmrc | ||
COPY ./versions.json ./versions.json | ||
|
@@ -92,7 +96,7 @@ ENV NODE_MAJOR=20 | |
|
||
RUN /bin/sh -c set -eux; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends bash curl openssh-client git build-essential pkg-config libssl-dev clang lld libclang-dev ca-certificates jq gnupg binutils-mips-linux-gnu python3 python3-pip; \ | ||
apt-get install -y --no-install-recommends bash curl openssh-client git build-essential ca-certificates jq gnupg binutils-mips-linux-gnu python3 python3-pip; \ | ||
mkdir -p /etc/apt/keyrings; \ | ||
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \ | ||
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ | ||
|
@@ -103,7 +107,7 @@ RUN /bin/sh -c set -eux; \ | |
apt-get install -y nodejs docker-ce-cli; \ | ||
ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt; \ | ||
npm i -g depcheck; \ | ||
pip install slither-analyzer==$(jq -r .slither < versions.json) capstone pyelftools; \ | ||
pip install capstone pyelftools; \ | ||
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | bash; \ | ||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ | ||
rm -rf /var/lib/apt/lists/*; \ | ||
|
@@ -138,3 +142,13 @@ ENV SHELL=/bin/bash | |
ENV BASH=/bin/bash | ||
|
||
ENTRYPOINT ["/bin/bash", "-c"] | ||
|
||
FROM base-builder as rust-builder | ||
|
||
# Copy the rust installation, alongside the installed toolchains | ||
COPY --from=rust-build /root/.cargo /root/.cargo | ||
COPY --from=rust-build /root/.rustup /root/.rustup | ||
|
||
# copy the rust installation, alongside the installed toolchains | ||
COPY --from=rust-build /root/.cargo/bin /root/.cargo/bin | ||
COPY --from=rust-build /root/.rustup /root/.rustup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters