From 8148498247cbeabe9c954495bc53882062a17e98 Mon Sep 17 00:00:00 2001 From: Kazunori Kimura Date: Thu, 4 Nov 2021 17:04:55 +0900 Subject: [PATCH] put ruby installation to Dockerfile for caching followup of Merge pull request #2429 image size : 2.83GB / 14.4.1 is 2.69GB I will try to make smaller .. --- Dockerfile | 26 ++++++++++++++++++++++++++ assets/build/install.sh | 19 ++----------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 88fd8cb30e..e9df256b2e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/assets/build/install.sh b/assets/build/install.sh index d8f48a531b..b78d5a51db 100755 --- a/assets/build/install.sh +++ b/assets/build/install.sh @@ -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 @@ -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" @@ -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