mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 18:12:55 +01:00
Support using OS other than Debian as base for custom images
Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com>
This commit is contained in:
parent
703c30315e
commit
0dea43ac3b
14 changed files with 345 additions and 226 deletions
|
|
@ -16,69 +16,80 @@ JEMALLOC_DOWNLOAD_URL="https://github.com/jemalloc/jemalloc/releases/download/${
|
|||
BUNDLER_VERSION=${3:-""}
|
||||
RUBYGEMS_VERSION=${4:-""}
|
||||
|
||||
# Install needed packages
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends bison dpkg-dev libgdbm-dev autoconf
|
||||
|
||||
# Download jemalloc
|
||||
mkdir -p /usr/src/jemalloc
|
||||
cd /usr/src/jemalloc
|
||||
curl --retry 6 -L -so jemalloc.tar.bz2 ${JEMALLOC_DOWNLOAD_URL}
|
||||
echo "${JEMALLOC_DOWNLOAD_SHA256} jemalloc.tar.bz2" | sha256sum -c -
|
||||
function build_debian() {
|
||||
# Install needed packages
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends bison dpkg-dev libgdbm-dev autoconf
|
||||
|
||||
# Install jemalloc
|
||||
tar -xjf jemalloc.tar.bz2
|
||||
rm jemalloc.tar.bz2
|
||||
cd jemalloc-${JEMALLOC_VERSION}
|
||||
./autogen.sh --prefix=/usr --enable-prof
|
||||
make -j "$(nproc)" install
|
||||
cd /tmp
|
||||
# Download jemalloc
|
||||
mkdir -p /usr/src/jemalloc
|
||||
cd /usr/src/jemalloc
|
||||
curl --retry 6 -L -so jemalloc.tar.bz2 ${JEMALLOC_DOWNLOAD_URL}
|
||||
echo "${JEMALLOC_DOWNLOAD_SHA256} jemalloc.tar.bz2" | sha256sum -c -
|
||||
|
||||
# Download Ruby
|
||||
curl -fsSL "$RUBY_DOWNLOAD_URL" -o ruby.tar.gz
|
||||
echo "${RUBY_DOWNLOAD_SHA256} ruby.tar.gz" | sha256sum -c -
|
||||
# Install jemalloc
|
||||
tar -xjf jemalloc.tar.bz2
|
||||
rm jemalloc.tar.bz2
|
||||
cd jemalloc-${JEMALLOC_VERSION}
|
||||
./autogen.sh --prefix=/usr --enable-prof
|
||||
make -j "$(nproc)" install
|
||||
cd /tmp
|
||||
|
||||
# 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
|
||||
# Download Ruby
|
||||
curl -fsSL "$RUBY_DOWNLOAD_URL" -o ruby.tar.gz
|
||||
echo "${RUBY_DOWNLOAD_SHA256} ruby.tar.gz" | sha256sum -c -
|
||||
|
||||
# Unpack Ruby
|
||||
mkdir -p /usr/src/ruby
|
||||
tar -xzf ruby.tar.gz -C /usr/src/ruby --strip-components=1
|
||||
rm ruby.tar.gz
|
||||
cd /usr/src/ruby
|
||||
# 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
|
||||
|
||||
# Apply patches
|
||||
if [[ -d "/patches/ruby/$RUBY_VERSION" ]]; then
|
||||
for i in "/patches/ruby/$RUBY_VERSION"/*.patch; do
|
||||
echo "$i..."
|
||||
patch -p1 -i "$i"
|
||||
done
|
||||
# Unpack Ruby
|
||||
mkdir -p /usr/src/ruby
|
||||
tar -xzf ruby.tar.gz -C /usr/src/ruby --strip-components=1
|
||||
rm ruby.tar.gz
|
||||
cd /usr/src/ruby
|
||||
|
||||
# Apply patches
|
||||
if [[ -d "/patches/ruby/$RUBY_VERSION" ]]; then
|
||||
for i in "/patches/ruby/$RUBY_VERSION"/*.patch; do
|
||||
echo "$i..."
|
||||
patch -p1 -i "$i"
|
||||
done
|
||||
fi
|
||||
|
||||
# Compile
|
||||
# This is needed for Ruby < 3.1 on Debian bullseye: https://bugs.ruby-lang.org/issues/18409
|
||||
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
|
||||
|
||||
# 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
|
||||
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' ]
|
||||
}
|
||||
|
||||
BUILD_OS=${BUILD_OS:-debian}
|
||||
|
||||
if [[ $BUILD_OS =~ debian ]]; then
|
||||
build_debian "$@"
|
||||
elif [[ $BUILD_OS =~ ubi ]]; then
|
||||
build_ubi "$@"
|
||||
fi
|
||||
|
||||
# Compile
|
||||
# This is needed for Ruby < 3.1 on Debian bullseye: https://bugs.ruby-lang.org/issues/18409
|
||||
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
|
||||
|
||||
# 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
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue