From f0c2f81abf6e514d22f008cf85aebe0c59e4cfec Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Mon, 8 Apr 2024 19:40:26 -0700 Subject: [PATCH] Use ruby-build --- Dockerfile | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index d100618..1b6a47d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,27 +7,54 @@ ARG RUBY_VERSION=3.2 # build phase, but not leak into the final image and run phase. ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update -qq \ +# Install system dependencies. +RUN apt-get update --quiet=2 \ + && apt-get install --quiet --yes \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg + +# Install Ruby dependencies. +RUN apt-get update --quiet=2 \ && apt-get install --yes --no-install-recommends \ + autoconf \ + bison \ + patch \ build-essential \ - ca-certificates \ - wget \ + rustc \ libssl-dev \ + libyaml-dev \ + libreadline6-dev \ + zlib1g-dev \ + libgmp-dev \ + libncurses5-dev \ + libffi-dev \ + libgdbm6 \ + libgdbm-dev \ + libdb-dev \ + uuid-dev \ + # Other dependencies... default-libmysqlclient-dev \ - clang clang-tools \ + clang \ + clang-tools \ llvm \ valgrind \ netcat RUN update-ca-certificates -RUN wget https://github.com/postmodern/ruby-install/releases/download/v0.9.0/ruby-install-0.9.0.tar.gz \ - && tar -xzvf ruby-install-0.9.0.tar.gz \ - && cd ruby-install-0.9.0 \ - && make install - -RUN ruby-install --system ruby ${RUBY_VERSION} -RUN ruby --version +RUN if which ruby >/dev/null 2>&1; then \ + echo "Ruby is already installed: $(ruby --version)"; \ + else \ + curl --location \ + "https://github.com/rbenv/ruby-build/archive/refs/tags/$(basename $(curl --location --silent --output /dev/null --write-out %{url_effective} https://github.com/rbenv/ruby-build/releases/latest)).tar.gz" \ + | tar --extract --gzip \ + && PREFIX=/usr/local ./ruby-build-*/install.sh \ + && rm -rf ./ruby-build-*/install.sh \ + && ruby-build ${RUBY_VERSION}.0 /usr/local \ + && echo "Installed Ruby: $(ruby --version)"; \ + fi WORKDIR /app COPY . .