Skip to content

Commit

Permalink
ci: merge docker images (solana-labs#35078)
Browse files Browse the repository at this point in the history
* ci: add new ci docker image

* ci: use the new docker image

* fix shellcheck

* add readme for the new docker image

* remove old docker images

* remove unused check in docs/build.sh

* use the new image in net.sh
  • Loading branch information
yihau authored Feb 7, 2024
1 parent b36d1e2 commit 8363ebf
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 146 deletions.
4 changes: 2 additions & 2 deletions .buildkite/scripts/build-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ EOF

# shellcheck disable=SC2016
group "bench" \
"$(build_steps "bench-part-1" ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/bench/part1.sh")" \
"$(build_steps "bench-part-2" ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/bench/part2.sh")"
"$(build_steps "bench-part-1" "ci/docker-run-default-image.sh ci/bench/part1.sh")" \
"$(build_steps "bench-part-2" "ci/docker-run-default-image.sh ci/bench/part2.sh")"
6 changes: 3 additions & 3 deletions .buildkite/scripts/build-stable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ partitions=$(
cat <<EOF
{
"name": "partitions",
"command": ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_stable_docker_image ci/stable/run-partition.sh",
"command": "ci/docker-run-default-image.sh ci/stable/run-partition.sh",
"timeout_in_minutes": 30,
"agent": "$agent",
"parallelism": 2,
Expand All @@ -25,7 +25,7 @@ local_cluster_partitions=$(
cat <<EOF
{
"name": "local-cluster",
"command": ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_stable_docker_image ci/stable/run-local-cluster-partially.sh",
"command": "ci/docker-run-default-image.sh ci/stable/run-local-cluster-partially.sh",
"timeout_in_minutes": 30,
"agent": "$agent",
"parallelism": 5,
Expand All @@ -38,7 +38,7 @@ localnet=$(
cat <<EOF
{
"name": "localnet",
"command": ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_stable_docker_image ci/stable/run-localnet.sh",
"command": "ci/docker-run-default-image.sh ci/stable/run-localnet.sh",
"timeout_in_minutes": 30,
"agent": "$agent"
}
Expand Down
16 changes: 8 additions & 8 deletions ci/buildkite-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ wait_step() {
}

all_test_steps() {
command_step checks1 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-checks.sh" 20 check
command_step checks2 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-dev-context-only-utils.sh check-bins" 15 check
command_step checks3 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-dev-context-only-utils.sh check-all-targets" 15 check
command_step checks1 "ci/docker-run-default-image.sh ci/test-checks.sh" 20 check
command_step checks2 "ci/docker-run-default-image.sh ci/test-dev-context-only-utils.sh check-bins" 15 check
command_step checks3 "ci/docker-run-default-image.sh ci/test-dev-context-only-utils.sh check-all-targets" 15 check
wait_step

# Full test suite
Expand All @@ -156,7 +156,7 @@ all_test_steps() {
^ci/rust-version.sh \
^ci/test-docs.sh \
; then
command_step doctest ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_stable_docker_image ci/test-docs.sh" 15
command_step doctest "ci/docker-run-default-image.sh ci/test-docs.sh" 15
else
annotate --style info --context test-docs \
"Docs skipped as no .rs files were modified"
Expand All @@ -182,7 +182,7 @@ all_test_steps() {
cargo-test-sbf$ \
; then
cat >> "$output_file" <<"EOF"
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_stable_docker_image ci/test-stable-sbf.sh"
- command: "ci/docker-run-default-image.sh ci/test-stable-sbf.sh"
name: "stable-sbf"
timeout_in_minutes: 35
artifact_paths: "sbf-dumps.tar.bz2"
Expand Down Expand Up @@ -226,7 +226,7 @@ EOF
^ci/test-stable.sh \
^sdk/ \
; then
command_step wasm ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_stable_docker_image ci/test-wasm.sh" 20
command_step wasm "ci/docker-run-default-image.sh ci/test-wasm.sh" 20
else
annotate --style info \
"wasm skipped as no relevant files were modified"
Expand Down Expand Up @@ -258,7 +258,7 @@ EOF
^ci/test-coverage.sh \
^scripts/coverage.sh \
; then
command_step coverage ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-coverage.sh" 80
command_step coverage "ci/docker-run-default-image.sh ci/test-coverage.sh" 80
else
annotate --style info --context test-coverage \
"Coverage skipped as no .rs files were modified"
Expand Down Expand Up @@ -296,7 +296,7 @@ pull_or_push_steps() {

if [ -z "$diff_other_than_version_bump" ]; then
echo "Diff only contains version bump."
command_step checks ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-checks.sh" 20
command_step checks "ci/docker-run-default-image.sh ci/test-checks.sh" 20
exit 0
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion ci/buildkite-secondary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Pull requests to not run these steps.
steps:
- name: "cargo audit"
command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_stable_docker_image ci/do-audit.sh"
command: "ci/docker-run-default-image.sh ci/do-audit.sh"
agents:
queue: "release-build"
timeout_in_minutes: 10
Expand Down
10 changes: 5 additions & 5 deletions ci/buildkite-solana-private.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ wait_step() {
}

all_test_steps() {
command_step checks ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-checks.sh" 20
command_step checks "ci/docker-run-default-image.sh ci/test-checks.sh" 20
wait_step

# Full test suite
Expand All @@ -146,7 +146,7 @@ all_test_steps() {
^ci/rust-version.sh \
^ci/test-docs.sh \
; then
command_step doctest ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_stable_docker_image ci/test-docs.sh" 15
command_step doctest "ci/docker-run-default-image.sh ci/test-docs.sh" 15
else
annotate --style info --context test-docs \
"Docs skipped as no .rs files were modified"
Expand All @@ -168,7 +168,7 @@ all_test_steps() {
^sdk/ \
; then
cat >> "$output_file" <<"EOF"
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_stable_docker_image ci/test-stable-sbf.sh"
- command: "ci/docker-run-default-image.sh ci/test-stable-sbf.sh"
name: "stable-sbf"
timeout_in_minutes: 35
artifact_paths: "sbf-dumps.tar.bz2"
Expand Down Expand Up @@ -208,7 +208,7 @@ EOF
^ci/test-stable.sh \
^sdk/ \
; then
command_step wasm ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_stable_docker_image ci/test-wasm.sh" 20
command_step wasm "ci/docker-run-default-image.sh ci/test-wasm.sh" 20
else
annotate --style info \
"wasm skipped as no relevant files were modified"
Expand Down Expand Up @@ -238,7 +238,7 @@ EOF
^ci/test-coverage.sh \
^scripts/coverage.sh \
; then
command_step coverage ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-coverage.sh" 80
command_step coverage "ci/docker-run-default-image.sh ci/test-coverage.sh" 80
else
annotate --style info --context test-coverage \
"Coverage skipped as no .rs files were modified"
Expand Down
2 changes: 1 addition & 1 deletion ci/dependabot-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fi

source ci/rust-version.sh stable

ci/docker-run.sh $rust_nightly_docker_image ci/dependabot-updater.sh
ci/docker-run-default-image.sh ci/dependabot-updater.sh

if [[ $(git status --short :**/Cargo.lock | wc -l) -eq 0 ]]; then
echo --- ok
Expand Down
10 changes: 10 additions & 0 deletions ci/docker-run-default-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e

here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# shellcheck disable=SC1091
source "$here/rust-version.sh"

"$here/docker-run.sh" "${ci_docker_image:?}" "$@"
21 changes: 0 additions & 21 deletions ci/docker-rust-nightly/Dockerfile

This file was deleted.

42 changes: 0 additions & 42 deletions ci/docker-rust-nightly/README.md

This file was deleted.

20 changes: 0 additions & 20 deletions ci/docker-rust-nightly/build.sh

This file was deleted.

11 changes: 0 additions & 11 deletions ci/docker-rust/README.md

This file was deleted.

19 changes: 0 additions & 19 deletions ci/docker-rust/build.sh

This file was deleted.

26 changes: 23 additions & 3 deletions ci/docker-rust/Dockerfile → ci/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
FROM ubuntu:20.04

ARG \
RUST_VERSION=1.75.0 \
RUST_VERSION= \
RUST_NIGHTLY_VERSION= \
GOLANG_VERSION=1.21.3 \
NODE_MAJOR=18 \
SCCACHE_VERSION=v0.5.4
SCCACHE_VERSION=v0.5.4 \
GRCOV_VERSION=v0.8.18

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand All @@ -21,7 +23,10 @@ ENV \
CARGO_HOME=/usr/local/cargo \
PATH="$PATH:/usr/local/cargo/bin"

RUN apt-get update && \
RUN \
if [ -z "$RUST_VERSION" ]; then echo "ERROR: The RUST_VERSION argument is required!" && exit 1; fi && \
if [ -z "$RUST_NIGHTLY_VERSION" ]; then echo "ERROR: The RUST_NIGHTLY_VERSION argument is required!" && exit 1; fi && \
apt-get update && \
apt-get install --no-install-recommends -y \
# basic
tzdata \
Expand Down Expand Up @@ -65,6 +70,9 @@ RUN apt-get update && \
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 install $RUST_NIGHTLY_VERSION && \
rustup component add clippy --toolchain=$RUST_NIGHTLY_VERSION && \
rustup component add rustfmt --toolchain=$RUST_NIGHTLY_VERSION && \
rustup target add wasm32-unknown-unknown && \
cargo install cargo-audit && \
cargo install cargo-hack && \
Expand All @@ -74,6 +82,9 @@ RUN apt-get update && \
cargo install svgbob_cli && \
cargo install wasm-pack && \
cargo install rustfilt && \
rustup show && \
rustc --version && \
cargo --version && \
chmod -R a+w $CARGO_HOME $RUSTUP_HOME && \
rm -rf $CARGO_HOME/registry && \
# sccache
Expand Down Expand Up @@ -101,5 +112,14 @@ RUN apt-get update && \
chmod -R a+w /.config && \
mkdir /.npm && \
chmod -R a+w /.npm && \
# 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 && \
# clean lists
rm -rf /var/lib/apt/lists/*
11 changes: 11 additions & 0 deletions ci/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Docker image containing rust, rust nightly and some preinstalled packages used in CI

This image is manually maintained:

#### CLI

1. Edit
1. `ci/rust-version.sh` for rust and rust nightly version
2. `ci/docker/Dockerfile` for other packages
2. Ensure you're a member of the [Solana Docker Hub Organization](https://hub.docker.com/u/solanalabs/) and already `docker login`
3. Run `ci/docker/build.sh` to build/publish the new image
23 changes: 23 additions & 0 deletions ci/docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -e

here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# shellcheck disable=SC1091
source "$here/../rust-version.sh"

platform=()
if [[ $(uname -m) = arm64 ]]; then
# Ref: https://blog.jaimyn.dev/how-to-build-multi-architecture-docker-images-on-an-m1-mac/#tldr
platform+=(--platform linux/amd64)
fi

echo "build image: ${ci_docker_image:?}"
docker build "${platform[@]}" \
-f "$here/Dockerfile" \
--build-arg "RUST_VERSION=${rust_stable:?}" \
--build-arg "RUST_NIGHTLY_VERSION=${rust_nightly:?}" \
-t "$ci_docker_image" .

docker push "$ci_docker_image"
2 changes: 1 addition & 1 deletion ci/publish-crate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ for Cargo_toml in $Cargo_tomls; do
echo "Attempt ${i} of ${numRetries}"
# The rocksdb package does not build with the stock rust docker image so use
# the solana rust docker image
if ci/docker-run.sh "$rust_stable_docker_image" bash -exc "cd $crate; $cargoCommand"; then
if ci/docker-run-default-image.sh bash -exc "cd $crate; $cargoCommand"; then
break
fi

Expand Down
Loading

0 comments on commit 8363ebf

Please sign in to comment.