ci: reorg docker images (#33815)

* ci: remove unnecessary args from docker-run.sh

* ci: remove cargo uninstall from buildkite post checkout

* ci: reorg docker images

* ci: add mscgen for docs
This commit is contained in:
Yihau Chen 2023-11-03 20:32:38 +08:00 committed by GitHub
parent 43668c4246
commit 662ac8bc86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 122 additions and 87 deletions

View File

@ -38,10 +38,3 @@ source ci/env.sh
kill -9 "$victim" || true
done
)
# HACK: These are in our docker images, need to be removed from CARGO_HOME
# because we try to cache downloads across builds with CARGO_HOME
# cargo lacks a facility for "system" tooling, always tries CARGO_HOME first
cargo uninstall cargo-audit &>/dev/null || true
cargo uninstall svgbob_cli &>/dev/null || true
cargo uninstall mdbook &>/dev/null || true

View File

@ -42,9 +42,6 @@ ARGS=(
)
if [[ -n $CI ]]; then
# Share the real ~/.cargo between docker containers in CI for speed
ARGS+=(--volume "$HOME:/home")
if [[ -n $BUILDKITE ]]; then
# I hate buildkite-esque echo is leaking into this generic shell wrapper.
# but it's easiest to notify to users, and properly guarded under $BUILDKITE_ env
@ -66,16 +63,7 @@ if [[ -n $CI ]]; then
)
fi
fi
else
# Avoid sharing ~/.cargo when building locally to avoid a mixed macOS/Linux
# ~/.cargo
ARGS+=(--volume "$PWD:/home")
fi
ARGS+=(--env "HOME=/home" --env "CARGO_HOME=/home/.cargo")
# kcov tries to set the personality of the binary which docker
# doesn't allow by default.
ARGS+=(--security-opt "seccomp=unconfined")
# Ensure files are created with the current host uid/gid
if [[ -z "$SOLANA_DOCKER_RUN_NOSETUID" ]]; then

View File

@ -1,17 +1,21 @@
FROM solanalabs/rust:1.73.0
ARG date
RUN set -x \
&& rustup install nightly-$date \
&& rustup component add clippy --toolchain=nightly-$date \
&& rustup component add rustfmt --toolchain=nightly-$date \
&& rustup show \
&& rustc --version \
&& cargo --version \
&& cargo install grcov \
&& rustc +nightly-$date --version \
&& cargo +nightly-$date --version \
# codecov
&& curl -Os https://uploader.codecov.io/latest/linux/codecov \
&& chmod +x codecov \
&& mv codecov /usr/bin
ARG date
ARG GRCOV_VERSION=v0.8.18
RUN \
rustup install nightly-$date && \
rustup component add clippy --toolchain=nightly-$date && \
rustup component add rustfmt --toolchain=nightly-$date && \
rustup show && \
rustc --version && \
cargo --version && \
# grcov
curl -LOsS "https://github.com/mozilla/grcov/releases/download/$GRCOV_VERSION/grcov-x86_64-unknown-linux-musl.tar.bz2" && \
tar -xf grcov-x86_64-unknown-linux-musl.tar.bz2 && \
mv ./grcov $CARGO_HOME/bin && \
rm grcov-x86_64-unknown-linux-musl.tar.bz2 && \
# codecov
curl -Os https://uploader.codecov.io/latest/linux/codecov && \
chmod +x codecov && \
mv codecov /usr/bin

View File

@ -1,55 +1,105 @@
# Note: when the rust version is changed also modify
# ci/rust-version.sh to pick up the new image tag
FROM rust:1.73.0-bullseye
FROM ubuntu:20.04
ARG NODE_MAJOR=18
ARG \
RUST_VERSION=1.73.0 \
GOLANG_VERSION=1.21.3 \
NODE_MAJOR=18 \
SCCACHE_VERSION=v0.5.4
RUN set -x \
&& apt update \
&& apt-get install apt-transport-https \
&& echo deb https://apt.buildkite.com/buildkite-agent stable main > /etc/apt/sources.list.d/buildkite-agent.list \
&& apt-key adv --no-tty --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 32A37959C2FA5C3C99EFBC32A79206696452D198 \
&& apt update \
&& apt install -y \
buildkite-agent \
clang \
cmake \
jq \
lcov \
libudev-dev \
mscgen \
nodejs \
net-tools \
rsync \
sudo \
golang \
unzip \
lld \
protobuf-compiler \
\
&& apt remove -y libcurl4-openssl-dev \
# node
&& sudo apt-get update \
&& sudo apt-get install -y ca-certificates curl gnupg \
&& sudo mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo 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" | sudo tee /etc/apt/sources.list.d/nodesource.list \
&& sudo apt-get update \
&& sudo apt-get install nodejs -y \
&& node --version \
&& npm --version \
# rust
&& rustup component add rustfmt \
&& rustup component add clippy \
&& rustup target add wasm32-unknown-unknown \
&& cargo install cargo-audit \
&& cargo install cargo-hack \
&& cargo install cargo-sort \
&& cargo install mdbook \
&& cargo install mdbook-linkcheck \
&& cargo install svgbob_cli \
&& cargo install wasm-pack \
&& cargo install sccache \
&& rustc --version \
&& cargo --version \
&& rm -rf /var/lib/apt/lists/*
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV \
DEBIAN_FRONTEND=noninteractive \
TZ=UTC
# golang
ENV PATH="/usr/local/go/bin:$PATH"
# rust
ENV \
RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH="$PATH:/usr/local/cargo/bin"
RUN apt-get update && \
apt-get install --no-install-recommends -y \
# basic
tzdata \
apt-transport-https \
sudo \
build-essential \
git \
vim \
jq \
ca-certificates \
curl \
gnupg \
lld \
cmake \
# docs
mscgen \
# solana compiling
libssl-dev \
libudev-dev \
pkg-config \
zlib1g-dev \
llvm \
clang \
cmake \
make \
libprotobuf-dev \
protobuf-compiler \
&& \
# buildkite
curl -fsSL https://keys.openpgp.org/vks/v1/by-fingerprint/32A37959C2FA5C3C99EFBC32A79206696452D198 | gpg --dearmor -o /usr/share/keyrings/buildkite-agent-archive-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/buildkite-agent-archive-keyring.gpg] https://apt.buildkite.com/buildkite-agent stable main" | tee /etc/apt/sources.list.d/buildkite-agent.list && \
apt-get update && \
apt-get install -y buildkite-agent && \
# gh
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && \
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \
apt-get update && \
apt-get install -y gh && \
# rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs/ | sh -s -- --no-modify-path --profile minimal --default-toolchain $RUST_VERSION -y && \
rustup component add rustfmt && \
rustup component add clippy && \
rustup target add wasm32-unknown-unknown && \
cargo install cargo-audit && \
cargo install cargo-hack && \
cargo install cargo-sort && \
cargo install mdbook && \
cargo install mdbook-linkcheck && \
cargo install svgbob_cli && \
cargo install wasm-pack && \
cargo install rustfilt && \
chmod -R a+w $CARGO_HOME $RUSTUP_HOME && \
rm -rf $CARGO_HOME/registry && \
# sccache
curl -LOsS "https://github.com/mozilla/sccache/releases/download/$SCCACHE_VERSION/sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl.tar.gz" && \
tar -xzf "sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl.tar.gz" && \
mv "sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl"/sccache "$CARGO_HOME/bin/" && \
rm "sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl.tar.gz" && \
rm -rf "sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl" && \
# nextest
curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C "$CARGO_HOME/bin" && \
# golang
curl -LOsS "https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz" && \
tar -C /usr/local -xzf "go$GOLANG_VERSION.linux-amd64.tar.gz" && \
rm "go$GOLANG_VERSION.linux-amd64.tar.gz" && \
# nodejs
sudo mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo 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" | sudo tee /etc/apt/sources.list.d/nodesource.list && \
sudo apt-get update && \
sudo apt-get install -y nodejs && \
# setup path
mkdir /.cache && \
chmod -R a+w /.cache && \
mkdir /.config && \
chmod -R a+w /.config && \
mkdir /.npm && \
chmod -R a+w /.npm && \
# clean lists
rm -rf /var/lib/apt/lists/*