From a00159f06f57545829b251a8ce51fa872cc4eadd Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 21 Jun 2022 22:59:02 +0800 Subject: [PATCH] Add a way to pin RubyGems and pin to 3.2 --- .gitlab/ci/gitlab.images.yml | 2 ++ Dockerfile.custom | 4 +++- scripts/install-ruby | 4 ++++ scripts/lib/custom-docker-build | 15 +++++++++++++++ scripts/lib/custom-docker.sh | 2 +- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/gitlab.images.yml b/.gitlab/ci/gitlab.images.yml index 98a3da8..5bd7f41 100644 --- a/.gitlab/ci/gitlab.images.yml +++ b/.gitlab/ci/gitlab.images.yml @@ -4,6 +4,7 @@ gitlab: - .build_and_push stage: gitlab variables: + RUBYGEMS: '3.2' LFS: '2.9' YARN: '1.22' GRAPHICSMAGICK: '1.3.36' @@ -23,6 +24,7 @@ gitlab-assets: - .build_and_push stage: gitlab-assets variables: + RUBYGEMS: '3.2' LFS: '2.9' YARN: '1.22' GRAPHICSMAGICK: '1.3.36' diff --git a/Dockerfile.custom b/Dockerfile.custom index d8e7ff2..510bea4 100644 --- a/Dockerfile.custom +++ b/Dockerfile.custom @@ -17,8 +17,9 @@ ENV PATH $PATH:/usr/local/go/bin ARG RUBY_VERSION ARG RUBY_DOWNLOAD_SHA256 ARG BUNDLER_VERSION +ARG RUBYGEMS_VERSION -RUN if [ -n "$RUBY_VERSION" ]; then /scripts/install-ruby $RUBY_VERSION $RUBY_DOWNLOAD_SHA256 $BUNDLER_VERSION && ruby --version; fi +RUN if [ -n "$RUBY_VERSION" ]; then /scripts/install-ruby "$RUBY_VERSION" "$RUBY_DOWNLOAD_SHA256" "$BUNDLER_VERSION" "$RUBYGEMS_VERSION" && ruby --version; fi # Git ARG GIT_VERSION @@ -107,6 +108,7 @@ RUN /scripts/validate-binaries-architecture # Set as env variables all versions configured ENV RUBY_VERSION=${RUBY_VERSION} \ + RUBYGEMS_VERSION=${RUBYGEMS_VERSION} \ GIT_VERSION=${GIT_VERSION} \ CHROME_VERSION=${CHROME_VERSION} \ NODE_VERSION=${NODE_INSTALL_VERSION} \ diff --git a/scripts/install-ruby b/scripts/install-ruby index 7b198db..f152c5c 100755 --- a/scripts/install-ruby +++ b/scripts/install-ruby @@ -14,6 +14,7 @@ JEMALLOC_DOWNLOAD_SHA256="2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7 JEMALLOC_DOWNLOAD_URL="https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2" BUNDLER_VERSION=${3:-""} +RUBYGEMS_VERSION=${4:-""} # Install needed packages apt-get update @@ -65,6 +66,9 @@ make install -j $(nproc) # Install specific version of bundler if provided if [[ "$BUNDLER_VERSION" != "" ]]; then gem install bundler -v $BUNDLER_VERSION; fi +# Install specific version of RubyGems if provided +if [[ "$RUBYGEMS_VERSION" != "" ]]; then gem update --system $RUBYGEMS_VERSION; fi + # Cleanup cd / rm -rf /usr/src/ruby /usr/src/jemalloc diff --git a/scripts/lib/custom-docker-build b/scripts/lib/custom-docker-build index 3d1b7b3..5557e3f 100755 --- a/scripts/lib/custom-docker-build +++ b/scripts/lib/custom-docker-build @@ -243,6 +243,20 @@ function print_bundler_args() { printf -- "--build-arg BUNDLER_VERSION=%s " "$BUNDLER_VERSION" } +function print_rubygems_args() { + case "$1" in + 3.1) + RUBYGEMS_VERSION=3.1.6 + ;; + 3.2) + RUBYGEMS_VERSION=3.2.33 + ;; + *) echo "Unknown rubygems version $1"; exit 1; + esac + + printf -- "--build-arg RUBYGEMS_VERSION=%s " "$RUBYGEMS_VERSION" +} + function print_gcloud_args() { case "$1" in 383) @@ -302,6 +316,7 @@ function parse_arguments() { DEBIAN) CUSTOM_IMAGE_VERSION=$version ;; RUBY) print_ruby_args $version ;; BUNDLER) print_bundler_args $version ;; + RUBYGEMS) print_rubygems_args $version ;; GOLANG) print_golang_args $version ;; CHROME) print_chrome_args $version ;; DOCKER) print_docker_args $version ;; diff --git a/scripts/lib/custom-docker.sh b/scripts/lib/custom-docker.sh index 6679433..ac20c5d 100644 --- a/scripts/lib/custom-docker.sh +++ b/scripts/lib/custom-docker.sh @@ -1,5 +1,5 @@ PATH_TOOLS=(DEBIAN RUBY GOLANG NODE POSTGRESQL) -TAG_TOOLS=(BUNDLER GIT LFS CHROME YARN GRAPHICSMAGICK PGBOUNCER BAZELISK DOCKER BUILDX GCLOUD KUBECTL) +TAG_TOOLS=(BUNDLER RUBYGEMS GIT LFS CHROME YARN GRAPHICSMAGICK PGBOUNCER BAZELISK DOCKER BUILDX GCLOUD KUBECTL) function get_image_path() { local path