gitlab-build-images/scripts/install-ruby
Kamil Trzciński d25cb10067 Apply thread allocations patch to Ruby 2.7
This makes us to compile Ruby 2.7 manually
and apply relevant patch.
2021-02-01 14:20:17 +01:00

50 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
set -xeou pipefail
# Based on https://github.com/docker-library/ruby/blob/master/2.7/buster/Dockerfile
RUBY_VERSION=${1}
RUBY_MAJOR=${1%.*} # strip last component
RUBY_DOWNLOAD_SHA256=${2}
RUBY_DOWNLOAD_URL="https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz"
# Download Ruby
curl -fsSL "$RUBY_DOWNLOAD_URL" -o ruby.tar.xz
echo "${RUBY_DOWNLOAD_SHA256} ruby.tar.xz" | sha256sum -c -
# Skip installing Gem docs
mkdir -p /usr/local/etc
echo 'install: --no-document' >> /usr/local/etc/gemrc
echo 'update: --no-document' >> /usr/local/etc/gemrc
# Install needed packages
apt-get update
apt-get install -y --no-install-recommends bison dpkg-dev libgdbm-dev ruby
# Unpack Ruby
mkdir -p /usr/src/ruby
tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1
rm ruby.tar.xz
cd /usr/src/ruby
# Apply patches
find /patches/ruby/$RUBY_VERSION -name '*.patch' -print0 | xargs -0 -n1 patch -p1 -i
./configure --enable-shared --disable-install-doc --disable-install-rdoc --disable-install-capi
make install -j $(nproc)
# Cleanup
cd /
rm -rf /usr/src/ruby
apt-get purge -y --auto-remove ruby
# Verify
# verify we have no "ruby" packages installed
! dpkg -l | grep -i ruby
[ "$(command -v ruby)" = '/usr/local/bin/ruby' ]
# rough smoke test
ruby --version
gem --version
bundle --version