Skip to content

Commit

Permalink
put ruby installation to Dockerfile for caching
Browse files Browse the repository at this point in the history
followup of Merge pull request sameersbn#2429
image size : 2.83GB / 14.4.1 is 2.69GB
I will try to make smaller ..
  • Loading branch information
kkimurak committed Dec 9, 2021
1 parent f1156cf commit c88e1fd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,32 @@ RUN set -ex && \
&& DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales \
&& rm -rf /var/lib/apt/lists/*

# install build dependencies for ruby
RUN set -ex \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
gcc libc6-dev make \
zlib1g-dev libssl-dev libgdbm-dev libreadline-dev \
&& rm -rf /var/lib/apt/lists/*

# build ruby from source
RUN set -ex \
&& RUBY_SRC_URL=https://cache.ruby-lang.org/pub/ruby/${RUBY_VERSION%.*}/ruby-${RUBY_VERSION}.tar.gz \
&& echo "Building ruby v${RUBY_VERSION} from source..." \
&& PWD_ORG="$PWD" \
&& mkdir /tmp/ruby && cd /tmp/ruby \
&& curl --remote-name -Ss "${RUBY_SRC_URL}" \
&& printf '%s ruby-%s.tar.gz' "${RUBY_SOURCE_SHA256SUM}" "${RUBY_VERSION}" | sha256sum -c - \
&& tar xzf ruby-"${RUBY_VERSION}".tar.gz && cd ruby-"${RUBY_VERSION}" \
&&./configure --disable-install-rdoc --enable-shared \
&& make -j"$(nproc)" \
&& make install \
&& cd "$PWD_ORG" && rm -rf /tmp/ruby

# RUN DEBIAN_FRONTEND=noninteractive apt-get purge -y --auto-remove \
# gcc libc6-dev make \
# zlib1g-dev libssl-dev libgdbm-dev libreadline-dev

COPY assets/build/ ${GITLAB_BUILD_DIR}/
RUN bash ${GITLAB_BUILD_DIR}/install.sh

Expand Down
19 changes: 2 additions & 17 deletions assets/build/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ GITLAB_WORKHORSE_BUILD_DIR=${GITLAB_INSTALL_DIR}/workhorse
GITLAB_PAGES_BUILD_DIR=/tmp/gitlab-pages
GITLAB_GITALY_BUILD_DIR=/tmp/gitaly

RUBY_SRC_URL=https://cache.ruby-lang.org/pub/ruby/${RUBY_VERSION%.*}/ruby-${RUBY_VERSION}.tar.gz

GEM_CACHE_DIR="${GITLAB_BUILD_DIR}/cache"

GOROOT=/tmp/go
Expand All @@ -20,9 +18,8 @@ PATH=${GOROOT}/bin:$PATH
export GOROOT PATH

BUILD_DEPENDENCIES="gcc g++ make patch pkg-config cmake paxctl \
libc6-dev \
libpq-dev zlib1g-dev libyaml-dev libssl-dev \
libgdbm-dev libreadline-dev libncurses5-dev libffi-dev \
libpq-dev libyaml-dev \
libncurses5-dev libffi-dev \
libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev \
gettext libkrb5-dev"

Expand All @@ -39,18 +36,6 @@ exec_as_git() {
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y ${BUILD_DEPENDENCIES}

# build ruby from source
echo "Building ruby v${RUBY_VERSION} from source..."
PWD_ORG="$PWD"
mkdir /tmp/ruby && cd /tmp/ruby
curl --remote-name -Ss "${RUBY_SRC_URL}"
printf '%s ruby-%s.tar.gz' "${RUBY_SOURCE_SHA256SUM}" "${RUBY_VERSION}" | sha256sum -c -
tar xzf ruby-"${RUBY_VERSION}".tar.gz && cd ruby-"${RUBY_VERSION}"
./configure --disable-install-rdoc --enable-shared
make -j"$(nproc)"
make install
cd "$PWD_ORG" && rm -rf /tmp/ruby

# PaX-mark ruby
# Applying the mark late here does make the build usable on PaX kernels, but
# still the build itself must be executed on a non-PaX kernel. It's done here
Expand Down

0 comments on commit c88e1fd

Please sign in to comment.