Skip to content

Commit 0d75e52

Browse files
committed
Use rv to install Rubies.
1 parent e5b00e0 commit 0d75e52

1 file changed

Lines changed: 15 additions & 23 deletions

File tree

Dockerfile

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,31 @@ RUN apt-get update && apt-get install -y \
2828
ca-certificates \
2929
libjemalloc-dev \
3030
parallel \
31+
xz-utils \
3132
&& rm -rf /var/lib/apt/lists/*
3233

33-
# Install ruby-install once (cached layer)
34-
RUN curl -fsSL https://github.com/postmodern/ruby-install/releases/download/v0.10.1/ruby-install-0.10.1.tar.gz | tar -xzf - \
35-
&& cd ruby-install-0.10.1 \
36-
&& make install \
37-
&& cd .. \
38-
&& rm -rf ruby-install-0.10.1
34+
# Install rv once (cached layer)
35+
ARG RV_VERSION=0.5.3
36+
ARG RV_DOWNLOAD_URL=https://github.com/spinel-coop/rv/releases/download/v${RV_VERSION}/rv-x86_64-unknown-linux-gnu.tar.xz
37+
38+
RUN mkdir -p /tmp/rv-install \
39+
&& curl -fsSL "$RV_DOWNLOAD_URL" | tar -xJ --strip-components=1 -C /tmp/rv-install \
40+
&& install -m 0755 /tmp/rv-install/rv /usr/local/bin/rv \
41+
&& rm -rf /tmp/rv-install
3942

4043
# Stage for Ruby 4.0.1 compilation
4144
FROM base AS ruby-4-0-1
4245

4346
RUN mkdir -p /opt/rubies && \
44-
MAKE_OPTS="-j$(nproc)" \
45-
ruby-install \
46-
--install-dir /opt/rubies/ruby-4.0.1 \
47-
--jobs $(nproc) \
48-
--cleanup \
49-
ruby 4.0.1 \
50-
-- --with-jemalloc \
51-
&& /opt/rubies/ruby-4.0.1/bin/gem install bundler --no-document
47+
RV_UPDATE_MODE=none rv ruby install --install-dir /opt/rubies 4.0.1 \
48+
&& rm -f /usr/local/bin/rv
5249

5350
# Stage for Ruby 3.4.5 compilation
5451
FROM base AS ruby-3-4-5
5552

5653
RUN mkdir -p /opt/rubies && \
57-
MAKE_OPTS="-j$(nproc)" \
58-
ruby-install \
59-
--install-dir /opt/rubies/ruby-3.4.5 \
60-
--jobs $(nproc) \
61-
--cleanup \
62-
ruby 3.4.5 \
63-
-- --with-jemalloc \
64-
&& /opt/rubies/ruby-3.4.5/bin/gem install bundler --no-document
54+
RV_UPDATE_MODE=none rv ruby install --install-dir /opt/rubies 3.4.5 \
55+
&& rm -f /usr/local/bin/rv
6556

6657
# Final stage - copy compiled Rubies
6758
FROM base AS final
@@ -70,7 +61,8 @@ FROM base AS final
7061
RUN git clone https://github.com/shellspec/shellspec.git /tmp/shellspec \
7162
&& cd /tmp/shellspec \
7263
&& make install PREFIX=/usr/local \
73-
&& rm -rf /tmp/shellspec
64+
&& rm -rf /tmp/shellspec \
65+
&& rm -f /usr/local/bin/rv
7466

7567
# Copy compiled Ruby installations from parallel stages
7668
COPY --from=ruby-4-0-1 /opt/rubies/ruby-4.0.1 /opt/rubies/ruby-4.0.1

0 commit comments

Comments
 (0)