Skip to content

Commit f1e3dc3

Browse files
base-images: build ruby from source (#14239)
Enables this on all container versions. Signed-off-by: David Korczynski <[email protected]>
1 parent 33223ed commit f1e3dc3

File tree

7 files changed

+43
-44
lines changed

7 files changed

+43
-44
lines changed

infra/base-images/base-builder-ruby/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ FROM gcr.io/oss-fuzz-base/base-builder
1818

1919
RUN git clone https://github.com/trailofbits/ruzzy.git $SRC/ruzzy
2020

21-
RUN install_ruby.sh
22-
ENV PATH="$PATH:/usr/local/rvm/rubies/ruby-3.3.1/bin"
23-
24-
RUN gem update --system 3.5.11
21+
RUN /usr/local/bin/install_ruby.sh
22+
RUN /usr/local/bin/gem update --system 3.5.11
2523

2624
# Install ruzzy
2725
WORKDIR $SRC/ruzzy

infra/base-images/base-builder-ruby/ubuntu-20-04.Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ FROM gcr.io/oss-fuzz-base/base-builder:ubuntu-20-04
1818

1919
RUN git clone https://github.com/trailofbits/ruzzy.git $SRC/ruzzy
2020

21-
RUN install_ruby.sh
22-
ENV PATH="$PATH:/usr/local/rvm/rubies/ruby-3.3.1/bin"
23-
24-
RUN gem update --system 3.5.11
21+
RUN /usr/local/bin/install_ruby.sh
22+
RUN /usr/local/bin/gem update --system 3.5.11
2523

2624
# Install ruzzy
2725
WORKDIR $SRC/ruzzy

infra/base-images/base-builder-ruby/ubuntu-24-04.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ FROM gcr.io/oss-fuzz-base/base-builder:ubuntu-24-04
1818

1919
RUN git clone https://github.com/trailofbits/ruzzy.git $SRC/ruzzy
2020

21-
RUN install_ruby.sh
22-
ENV PATH="$PATH:/usr/local/rvm/rubies/ruby-3.3.1/bin"
21+
RUN /usr/local/bin/install_ruby.sh
22+
RUN /usr/local/bin/gem update --system 3.5.11
2323

2424
RUN gem update --system 3.5.11
2525

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash -eux
22
# Copyright 2024 Google LLC
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,14 +15,19 @@
1515
#
1616
################################################################################
1717

18-
apt update
19-
apt install -y lsb-release software-properties-common gnupg2 binutils xz-utils libyaml-dev
20-
gpg2 --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
18+
echo "Starting ruby installation"
19+
RUBY_VERSION=3.3.1
20+
RUBY_DEPS="binutils xz-utils libyaml-dev libffi-dev zlib1g-dev"
21+
apt update && apt install -y $RUBY_DEPS
22+
curl -O https://cache.ruby-lang.org/pub/ruby/3.3/ruby-$RUBY_VERSION.tar.gz
23+
tar -xvf ruby-$RUBY_VERSION.tar.gz
24+
cd ruby-$RUBY_VERSION
25+
./configure
26+
make -j$(nproc)
27+
make install
28+
cd ../
2129

22-
curl -sSL https://get.rvm.io > ruby_installation.sh
23-
chmod +x ruby_installation.sh
24-
bash ruby_installation.sh stable
30+
# Clean up the sources.
31+
rm -rf ./ruby-$RUBY_VERSION ruby-$RUBY_VERSION.tar.gz
2532

26-
. /etc/profile.d/rvm.sh
27-
28-
rvm install ruby-3.3.1
33+
echo "Finished installing ruby"

infra/base-images/base-runner/Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ RUN wget https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.7/org.jaco
109109
COPY install_javascript.sh /
110110
RUN /install_javascript.sh && rm /install_javascript.sh
111111

112-
# Copy built ruby and ruzzy from builder
113-
COPY --from=base-ruby /usr/local/rvm /usr/local/rvm
114-
COPY --from=base-ruby /install/ruzzy /install/ruzzy
115-
COPY ruzzy /usr/local/bin/ruzzy
116-
ENV PATH="$PATH:/usr/local/rvm/rubies/ruby-3.3.1/bin"
117-
# RubyGems installation directory
118-
ENV GEM_HOME="$OUT/fuzz-gem"
119-
ENV GEM_PATH="/install/ruzzy"
112+
# Copy built ruby. It is up to the fuzzing harnesses
113+
# themselves to set GEM_HOME and GEM_PATH appropriately, as this depends
114+
# on how the harnesses are packaged.
115+
COPY --from=base-ruby /usr/local/bin/ruby /usr/local/bin/ruby
116+
COPY --from=base-ruby /usr/local/bin/gem /usr/local/bin/gem
117+
COPY --from=base-ruby /usr/local/lib/ruby /usr/local/lib/ruby
118+
COPY --from=base-ruby /usr/local/include/ruby-3.3.0 /usr/local/include/ruby-3.3.0
119+
120120

121121
# Do this last to make developing these files easier/faster due to caching.
122122
COPY bad_build_check \

infra/base-images/base-runner/ubuntu-20-04.Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,13 @@ RUN wget https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.7/org.jaco
109109
COPY install_javascript.sh /
110110
RUN /install_javascript.sh && rm /install_javascript.sh
111111

112-
# Copy built ruby and ruzzy from builder
113-
COPY --from=base-ruby /usr/local/rvm /usr/local/rvm
114-
COPY --from=base-ruby /install/ruzzy /install/ruzzy
115-
COPY ruzzy /usr/bin/ruzzy
116-
ENV PATH="$PATH:/usr/local/rvm/rubies/ruby-3.3.1/bin"
117-
# RubyGems installation directory
118-
ENV GEM_HOME="$OUT/fuzz-gem"
119-
ENV GEM_PATH="/install/ruzzy"
112+
# Copy built ruby. It is up to the fuzzing harnesses
113+
# themselves to set GEM_HOME and GEM_PATH appropriately, as this depends
114+
# on how the harnesses are packaged.
115+
COPY --from=base-ruby /usr/local/bin/ruby /usr/local/bin/ruby
116+
COPY --from=base-ruby /usr/local/bin/gem /usr/local/bin/gem
117+
COPY --from=base-ruby /usr/local/lib/ruby /usr/local/lib/ruby
118+
COPY --from=base-ruby /usr/local/include/ruby-3.3.0 /usr/local/include/ruby-3.3.0
120119

121120
# Do this last to make developing these files easier/faster due to caching.
122121
COPY bad_build_check \

infra/base-images/base-runner/ubuntu-24-04.Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,13 @@ RUN wget https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.7/org.jaco
109109
COPY install_javascript.sh /
110110
RUN /install_javascript.sh && rm /install_javascript.sh
111111

112-
# Copy built ruby and ruzzy from builder
113-
COPY --from=base-ruby /usr/local/rvm /usr/local/rvm
114-
COPY --from=base-ruby /install/ruzzy /install/ruzzy
115-
COPY ruzzy /usr/bin/ruzzy
116-
ENV PATH="$PATH:/usr/local/rvm/rubies/ruby-3.3.1/bin"
117-
# RubyGems installation directory
118-
ENV GEM_HOME="$OUT/fuzz-gem"
119-
ENV GEM_PATH="/install/ruzzy"
112+
# Copy built ruby. It is up to the fuzzing harnesses
113+
# themselves to set GEM_HOME and GEM_PATH appropriately, as this depends
114+
# on how the harnesses are packaged.
115+
COPY --from=base-ruby /usr/local/bin/ruby /usr/local/bin/ruby
116+
COPY --from=base-ruby /usr/local/bin/gem /usr/local/bin/gem
117+
COPY --from=base-ruby /usr/local/lib/ruby /usr/local/lib/ruby
118+
COPY --from=base-ruby /usr/local/include/ruby-3.3.0 /usr/local/include/ruby-3.3.0
120119

121120
# Do this last to make developing these files easier/faster due to caching.
122121
COPY bad_build_check \

0 commit comments

Comments
 (0)