Skip to content

Commit

Permalink
add ruby 3.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaffen committed Mar 19, 2024
1 parent 52008c7 commit 28e1ef2
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
118 changes: 118 additions & 0 deletions 3.2/jammy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#
# Fork of https://github.com/docker-library/ruby/blob/master/3.2/bookworm/Dockerfile
#

FROM buildpack-deps:jammy

# skip installing gem documentation
RUN set -eux; \
mkdir -p /usr/local/etc; \
{ \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc

ENV LANG C.UTF-8

# https://www.ruby-lang.org/en/news/2024/01/18/ruby-3-2-3-released/
ENV RUBY_VERSION 3.2.3
ENV RUBY_DOWNLOAD_URL https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.3.tar.xz
ENV RUBY_DOWNLOAD_SHA256 cfb231954b8c241043a538a4c682a1cca0b2016d835fee0b9e4a0be3ceba476b

# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
RUN set -eux; \
\
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
bison \
dpkg-dev \
libgdbm-dev \
ruby \
; \
rm -rf /var/lib/apt/lists/*; \
\
rustArch=; \
dpkgArch="$(dpkg --print-architecture)"; \
case "$dpkgArch" in \
'amd64') rustArch='x86_64-unknown-linux-gnu'; rustupUrl='https://static.rust-lang.org/rustup/archive/1.26.0/x86_64-unknown-linux-gnu/rustup-init'; rustupSha256='0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db' ;; \
'arm64') rustArch='aarch64-unknown-linux-gnu'; rustupUrl='https://static.rust-lang.org/rustup/archive/1.26.0/aarch64-unknown-linux-gnu/rustup-init'; rustupSha256='673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800' ;; \
esac; \
\
if [ -n "$rustArch" ]; then \
mkdir -p /tmp/rust; \
\
wget -O /tmp/rust/rustup-init "$rustupUrl"; \
echo "$rustupSha256 */tmp/rust/rustup-init" | sha256sum --check --strict; \
chmod +x /tmp/rust/rustup-init; \
\
export RUSTUP_HOME='/tmp/rust/rustup' CARGO_HOME='/tmp/rust/cargo'; \
export PATH="$CARGO_HOME/bin:$PATH"; \
/tmp/rust/rustup-init -y --no-modify-path --profile minimal --default-toolchain '1.74.1' --default-host "$rustArch"; \
\
rustc --version; \
cargo --version; \
fi; \
\
wget -O ruby.tar.xz "$RUBY_DOWNLOAD_URL"; \
echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum --check --strict; \
\
mkdir -p /usr/src/ruby; \
tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1; \
rm ruby.tar.xz; \
\
cd /usr/src/ruby; \
\
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
# warning: Insecure world writable dir
{ \
echo '#define ENABLE_PATH_CHECK 0'; \
echo; \
cat file.c; \
} > file.c.new; \
mv file.c.new file.c; \
\
autoconf; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \
--disable-install-doc \
--enable-shared \
${rustArch:+--enable-yjit} \
; \
make -j "$(nproc)"; \
make install; \
\
rm -rf /tmp/rust; \
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark > /dev/null; \
find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
\
cd /; \
rm -r /usr/src/ruby; \
# verify we have no "ruby" packages installed
if dpkg -l | grep -i ruby; then exit 1; fi; \
[ "$(command -v ruby)" = '/usr/local/bin/ruby' ]; \
# rough smoke test
ruby --version; \
gem --version; \
bundle --version

# don't create ".bundle" in all our apps
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $GEM_HOME/bin:$PATH
# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 1777 "$GEM_HOME"

CMD [ "irb" ]
6 changes: 6 additions & 0 deletions build_versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"full": "2.7.8",
"os": "focal"
},
{
"major": "3",
"minor": "3.2",
"full": "3.2.3",
"os": "jammy"
},
{
"major": "3",
"minor": "3.3",
Expand Down

0 comments on commit 28e1ef2

Please sign in to comment.