From 1f15ec8684e69e888e494a67bea6e2d8f9dd55cc Mon Sep 17 00:00:00 2001 From: Andrejs Cunskis Date: Sun, 1 May 2022 19:31:13 +0300 Subject: [PATCH] Add option to pass custom bundler version --- .gitlab/ci/qa.images.yml | 1 + Dockerfile.custom | 3 ++- scripts/custom-docker-build | 15 +++++++++++++++ scripts/install-ruby | 5 +++++ scripts/lib/custom-docker.sh | 2 +- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/qa.images.yml b/.gitlab/ci/qa.images.yml index bfc9fe1..845699d 100644 --- a/.gitlab/ci/qa.images.yml +++ b/.gitlab/ci/qa.images.yml @@ -4,6 +4,7 @@ LFS: '2.9' GIT: '2.33' RUBY: '2.7' + BUNDLER: '2.3' CHROME: '99' GCLOUD: '383' KUBECTL: '1.23' diff --git a/Dockerfile.custom b/Dockerfile.custom index 78818ea..6c9e01b 100644 --- a/Dockerfile.custom +++ b/Dockerfile.custom @@ -16,8 +16,9 @@ ENV PATH $PATH:/usr/local/go/bin # Ruby ARG RUBY_VERSION ARG RUBY_DOWNLOAD_SHA256 +ARG BUNDLER_VERSION -RUN if [ -n "$RUBY_VERSION" ]; then /scripts/install-ruby $RUBY_VERSION $RUBY_DOWNLOAD_SHA256 && ruby --version; fi +RUN if [ -n "$RUBY_VERSION" ]; then /scripts/install-ruby $RUBY_VERSION $RUBY_DOWNLOAD_SHA256 $BUNDLER_VERSION && ruby --version; fi # Git ARG GIT_VERSION diff --git a/scripts/custom-docker-build b/scripts/custom-docker-build index fea1104..53469ab 100755 --- a/scripts/custom-docker-build +++ b/scripts/custom-docker-build @@ -215,6 +215,20 @@ function print_ruby_args() { printf -- "--build-arg RUBY_DOWNLOAD_SHA256=%s " "$RUBY_DOWNLOAD_SHA256" } +function print_bundler_args() { + case "$1" in + 2.1) + BUNDLER_VERSION=2.1.4 + ;; + 2.3) + BUNDLER_VERSION=2.3.12 + ;; + *) echo "Unknown bundler version $1"; exit 1; + esac + + printf -- "--build-arg BUNDLER_VERSION=%s " "$BUNDLER_VERSION" +} + function print_gcloud_args() { case "$1" in 383) @@ -252,6 +266,7 @@ function parse_arguments() { case "$tool" in DEBIAN) CUSTOM_IMAGE_VERSION=$version ;; RUBY) print_ruby_args $version ;; + BUNDLER) print_bundler_args $version ;; GOLANG) print_golang_args $version ;; CHROME) print_chrome_args $version ;; DOCKER) print_docker_args $version ;; diff --git a/scripts/install-ruby b/scripts/install-ruby index ced00d9..38dfebb 100755 --- a/scripts/install-ruby +++ b/scripts/install-ruby @@ -13,6 +13,8 @@ JEMALLOC_VERSION=5.2.1 JEMALLOC_DOWNLOAD_SHA256="34330e5ce276099e2e8950d9335db5a875689a4c6a56751ef3b1d8c537f887f6" JEMALLOC_DOWNLOAD_URL="https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2" +BUNDLER_VERSION=${3:-""} + # Install needed packages apt-get update apt-get install -y --no-install-recommends bison dpkg-dev libgdbm-dev autoconf @@ -60,6 +62,9 @@ export LDFLAGS="-Wl,--no-as-needed" cflags="-fno-omit-frame-pointer" ./configure --enable-shared --with-jemalloc --disable-install-doc --disable-install-rdoc --disable-install-capi make install -j $(nproc) +# Install specific version of bundler if provided +if [[ "$BUNDLER_VERSION" != "" ]]; then gem install bundler -v $BUNDLER_VERSION; fi + # Cleanup cd / rm -rf /usr/src/ruby /usr/src/jemalloc diff --git a/scripts/lib/custom-docker.sh b/scripts/lib/custom-docker.sh index 4d5a46d..a790ca9 100644 --- a/scripts/lib/custom-docker.sh +++ b/scripts/lib/custom-docker.sh @@ -1,4 +1,4 @@ -TOOLS=(DEBIAN RUBY GOLANG GIT LFS CHROME NODE YARN POSTGRESQL GRAPHICSMAGICK PGBOUNCER BAZELISK GCLOUD KUBECTL) +TOOLS=(DEBIAN RUBY BUNDLER GOLANG GIT LFS CHROME NODE YARN POSTGRESQL GRAPHICSMAGICK PGBOUNCER BAZELISK GCLOUD KUBECTL) function get_image_name(){ local IMAGE_NAME