diff --git a/.gitlab/ci/gitaly.images.yml b/.gitlab/ci/gitaly.images.yml index a360a99..9335e70 100644 --- a/.gitlab/ci/gitaly.images.yml +++ b/.gitlab/ci/gitaly.images.yml @@ -9,8 +9,10 @@ gitaly: - OS: ['debian:bullseye'] RUBY: ['2.7', '3.0'] GOLANG: ['1.18', '1.19'] + RUST: ['1.65.0'] GIT: ['2.36'] - OS: ['ubi:8.6'] RUBY: ['2.7'] GOLANG: ['1.18'] + RUST: ['1.65.0'] GIT: ['2.36'] diff --git a/.gitlab/ci/gitlab.images.yml b/.gitlab/ci/gitlab.images.yml index 6deb90b..e174cb9 100644 --- a/.gitlab/ci/gitlab.images.yml +++ b/.gitlab/ci/gitlab.images.yml @@ -16,6 +16,7 @@ gitlab: GIT: ['2.36'] POSTGRESQL: ['11', '12', '13'] GOLANG: ['1.18', '1.19'] + RUST: ['1.65.0'] NODE: ['16.14'] CHROME: ['106', '107'] diff --git a/.gitlab/ci/kas.images.yml b/.gitlab/ci/kas.images.yml index 89142b4..677dc4b 100644 --- a/.gitlab/ci/kas.images.yml +++ b/.gitlab/ci/kas.images.yml @@ -4,6 +4,7 @@ gitlab-kas: - .build_and_push variables: GOLANG: '1.19' + RUST: '1.65.0' LFS: '2.9' CHROME: '107' NODE: '14.15' diff --git a/Dockerfile.custom b/Dockerfile.custom index 16c5db3..9b6703d 100644 --- a/Dockerfile.custom +++ b/Dockerfile.custom @@ -17,6 +17,8 @@ RUN /scripts/install-essentials ${BUILD_OS} ENV PATH $PATH:/usr/local/go/bin +ENV PATH /usr/local/cargo/bin:$PATH + # Ruby ARG RUBY_VERSION ARG RUBY_DOWNLOAD_SHA256 @@ -50,6 +52,11 @@ ARG GOLANG_DOWNLOAD_SHA256 RUN if [ -n "$INSTALL_GOLANG_VERSION" ] ; then /scripts/install-golang "${INSTALL_GOLANG_VERSION}" "${GOLANG_DOWNLOAD_SHA256}" && go version; fi +# Rust +ARG INSTALL_RUST_VERSION + +RUN if [ -n "$INSTALL_RUST_VERSION" ] ; then /scripts/install-rust "${INSTALL_RUST_VERSION}" && rustc version; fi + # Git LFS (https://git-lfs.github.com/) ARG LFS_VERSION ARG LFS_DOWNLOAD_SHA256 @@ -117,6 +124,7 @@ ENV RUBY_VERSION=${RUBY_VERSION} \ NODE_VERSION=${NODE_INSTALL_VERSION} \ YARN_VERSION=${YARN_INSTALL_VERSION} \ GOLANG_VERSION=${INSTALL_GOLANG_VERSION} \ + RUST_VERSION=${INSTALL_RUST_VERSION} \ LFS_VERSION=${LFS_VERSION} \ POSTGRES_VERSION=${POSTGRES_VERSION} \ GRAPHISMAGICK_VERSION=${GRAPHISMAGICK_VERSION} \ diff --git a/README.md b/README.md index 752d112..deb3f69 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Major components define image path. Base image is defined by `OS` component. Sup 1. `OS` 1. `RUBY` 1. `GOLANG` +1. `RUST` 1. `NODE` 1. `POSTGRES` @@ -88,6 +89,7 @@ new_image: OS: 'debian:bullseye' RUBY: '3.0' GOLANG: '1.15' + RUST: '1.65.0' GIT: '2.29' ``` diff --git a/scripts/install-rust b/scripts/install-rust new file mode 100755 index 0000000..d1d9f16 --- /dev/null +++ b/scripts/install-rust @@ -0,0 +1,42 @@ +#!/bin/bash + +set -xeou pipefail + +INSTALL_RUST_VERSION=${1} + +case "$TARGETARCH" in + "arm64") + RUST_TARGET="aarch64-unknown-linux-gnu" + ;; + "amd64") + RUST_TARGET="x86_64-unknown-linux-gnu" + ;; + *) + echo "target architecture not supported" + exit 1 + ;; +esac + +RUST_DOWNLOAD_URL="https://static.rust-lang.org/rustup/dist/$RUST_TARGET/rustup-init" + +RUSTUP_DEFAULT_TOOLCHAIN="$INSTALL_RUST_VERSION" +RUSTUP_HOME="/usr/local/rustup" + +CARGO_HOME="/usr/local/cargo" + +function build() { + curl --retry 3 --proto '=https' --tlsv1.2 -sSf "$RUST_DOWNLOAD_URL" > rustup-init + curl --retry 3 --proto '=https' --tlsv1.2 -sSf "$RUST_DOWNLOAD_URL.sha256" > rustup-init.sha256 + # Remove "target/$RUST_TARGET/release/" string from rustup-init.sha256 + sed -i "s:\*target/$RUST_TARGET/release/::" rustup-init.sha256 + sha256sum -c rustup-init.sha256 + chmod +x rustup-init + + # Need rustfmt for bindgen doc parsing + ./rustup-init --no-modify-path --default-toolchain "$RUSTUP_DEFAULT_TOOLCHAIN" --profile minimal --component rustfmt -y + rm rustup-init && rm rustup-init.sha256 + + chmod -R a+w "$RUSTUP_HOME" "$CARGO_HOME" +} + +build "$@" diff --git a/scripts/lib/custom-docker-build b/scripts/lib/custom-docker-build index c0d10b8..8c66ed3 100755 --- a/scripts/lib/custom-docker-build +++ b/scripts/lib/custom-docker-build @@ -61,6 +61,18 @@ function print_golang_args() { printf -- "--build-arg GOLANG_DOWNLOAD_SHA256=%q " "${GOLANG_DOWNLOAD_SHA256[*]}" } +function print_rust_args() { + case "$1" in + 1.65.0) + RUST_VERSION="1.65.0" + ;; + + *) fail "Unknown rust version $1" ;; + esac + + printf -- "--build-arg RUST_VERSION=%s " "$RUST_VERSION" +} + # If you add a new minor version here, be sure to check that the # Chrome versions can be found at https://www.ubuntuupdates.org/pm/google-chrome-stable. # ChromeDriver supports this: https://sites.google.com/chromium.org/driver/downloads @@ -339,6 +351,7 @@ function parse_arguments() { BUNDLER) print_bundler_args $version ;; RUBYGEMS) print_rubygems_args $version ;; GOLANG) print_golang_args $version ;; + RUST) print_rust_args $version ;; CHROME) print_chrome_args $version ;; DOCKER) print_docker_args $version ;; BUILDX) print_buildx_args $version ;; diff --git a/scripts/lib/custom-docker.sh b/scripts/lib/custom-docker.sh index 498ba67..a14a69d 100644 --- a/scripts/lib/custom-docker.sh +++ b/scripts/lib/custom-docker.sh @@ -1,7 +1,7 @@ # Note: Check out https://wiki.bash-hackers.org/syntax/pe for documentation on # various variable operations used in this script. -PATH_TOOLS=(DEBIAN OS UBI RUBY GOLANG NODE POSTGRESQL) +PATH_TOOLS=(DEBIAN OS UBI RUBY GOLANG RUST NODE POSTGRESQL) TAG_TOOLS=(BUNDLER RUBYGEMS GIT LFS CHROME YARN GRAPHICSMAGICK BAZELISK DOCKER BUILDX GCLOUD KUBECTL HELM) # Generate the docker image path using the components that were specified via @@ -10,6 +10,7 @@ TAG_TOOLS=(BUNDLER RUBYGEMS GIT LFS CHROME YARN GRAPHICSMAGICK BAZELISK DOCKER B # OS: debian:bullseye # RUBY: 2.7 # GOLANG: 1.19 +# RUST: 1.65.0 # GIT: 2.33 # POSTGRESQL: 11 # With the above variables, this function will return @@ -44,6 +45,7 @@ function get_image_path() { # OS: debian:bullseye # RUBY: 2.7 # GOLANG: 1.19 +# RUST: 1.65.0 # GIT: 2.33 # POSTGRESQL: 11 # For that job, this function will return