Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions containers/images/ruby-3.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
FROM sourcemation/debian-13-slim

# This Dockerfile originates from the official Docker Hub image. We have made modifications
# to improve readability and maintainability. Importantly, our images are automatically
# rebuilt and updated.
# License: MIT

ARG BUILD_DATE
ARG TARGETARCH

LABEL name="ruby-3.4" \
vendor="Sourcemation" \
url="https://Sourcemation.com/"\
licenses="2-clause BSDL " \
created="$BUILD_DATE" \
architecture="$TARGETARCH" \
summary="Ruby 3.4 on Debian 13 Slim Container" \
description="Provides Ruby 3.4 on Debian 13 Slim Container" \
version="3.4.10" \
org.opencontainers.image.source="https://github.com/Sourcemation/images" \
io.k8s.display-name="Ruby 3.4 on Debian 13 Slim Container" \
io.k8s.description="Provides Ruby 3.4 on Debian 13 Slim Container" \
io.openshift.tags="ruby-3.4 debian-13-slim"

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
; \
apt-get dist-clean

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

ENV LANG C.UTF-8

# https://www.ruby-lang.org/en/news/2026/07/14/ruby-3-4-10-released/
ENV RUBY_VERSION 3.4.10
ENV RUBY_DOWNLOAD_URL https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.10.tar.xz
ENV RUBY_DOWNLOAD_SHA256 6f32ad662baafc228d12030dbcd284f83b034dd4337b300dc84ac74d11a1eb68

# 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 \
dpkg-dev \
libgdbm-dev \
ruby \
autoconf \
bzip2 \
g++ \
gcc \
libbz2-dev \
libffi-dev \
libgdbm-compat-dev \
libglib2.0-dev \
libgmp-dev \
libncurses-dev \
libssl-dev \
libxml2-dev \
libxslt-dev \
libyaml-dev \
make \
wget \
xz-utils \
zlib1g-dev \
; \
\
rustArch=; \
dpkgArch="$(dpkg --print-architecture)"; \
case "$dpkgArch" in \
'amd64') rustArch='x86_64-unknown-linux-gnu'; rustupUrl='https://static.rust-lang.org/rustup/archive/1.28.2/x86_64-unknown-linux-gnu/rustup-init'; rustupSha256='20a06e644b0d9bd2fbdbfd52d42540bdde820ea7df86e92e533c073da0cdd43c' ;; \
'arm64') rustArch='aarch64-unknown-linux-gnu'; rustupUrl='https://static.rust-lang.org/rustup/archive/1.28.2/aarch64-unknown-linux-gnu/rustup-init'; rustupSha256='e3853c5a252fca15252d07cb23a1bdd9377a8c6f3efa01531109281ae47f841c' ;; \
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.91.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; \
\
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); printf "*%s\n", so }' \
| sort -u \
| xargs -r dpkg-query --search \
# https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file)
| awk 'sub(":$", "", $1) { print $1 }' \
| sort -u \
| xargs -r apt-mark manual \
; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
apt-get dist-clean; \
\
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
RUN set -eux; \
mkdir "$GEM_HOME"; \
# adjust permissions of GEM_HOME for running "gem install" as an arbitrary user
chmod 1777 "$GEM_HOME"

CMD [ "irb" ]
78 changes: 78 additions & 0 deletions containers/images/ruby-3.4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Ruby 3.4 packaged by Sourcemation

An open source purely object-oriented programming language with a focus on
simplicity and readability. Ruby 3.4 introduces performance improvements, YJIT
optimizations, and modernized language features.

This Ruby distribution is built from official source distributions by the
Sourcemation automation team. It is based on the `sourcemation/debian-13-slim`
base image, providing a highly optimized, clean, and secure environment.

## Usage

Run a temporary container with the Ruby REPL (`irb`) (don't forget the
`-it` argument).

```bash
docker run --rm -it sourcemation/ruby-3.4:latest
```

### Advanced usage examples

Example: create a Gemfile for a Ruby project, in your current directory:

```bash
docker run --rm -v "${PWD}:/your-project" -w "/your-project" sourcemation/ruby-3.4:latest bundle init
```

## Environment Vars, Ports, Volumes

This image uses the following environment variables:

```
PATH="/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
GEM_HOME="/usr/local/bundle"
BUNDLE_APP_CONFIG="/usr/local/bundle"
APP_VERSION="3.4.10"
APP_NAME="ruby-3.4"
```

This image exposes no ports by default.

Please note that the ports need to be either manually forwarded with the
`-p` option or let Docker choose some for you with the `-P` option.

## Contributing and Issues

We welcome your contributions! If you have new feature requests, want to report
a bug, or wish to submit a pull request with your code or an image request, you
can do so via the Sourcemation GitHub repository for this image.

- [Open a new issue (for feature requests, bug reports, or image requests)](https://github.com/Sourcemation/images/issues/new/choose)
- [Submit a pull request](https://github.com/Sourcemation/images/compare)

**Disclaimer:** The `sourcemation/ruby-3.4` image is not affiliated with
Yukihiro Matsumoto and the Ruby Community [the Ruby
Community](https://www.ruby-lang.org/en/community/). The respective
entities own the trademarks mentioned in the offering. The
`sourcemation/ruby-3.4` image is a separate project and is maintained by
[Sourcemation](https://sourcemation.com).

## Extra notes

### Image and its components Risk Analysis report

A detailed risk analysis report of the image and its components can be
found on the [Sourcemation
platform](https://www.sourcemation.com).

For more information, check out the [overview of
Ruby](https://www.ruby-lang.org/en/about/) page.

### Licenses

The base license for the solution (Ruby) is the [Ruby
License](https://www.ruby-lang.org/en/about/license.txt). The licenses
for each component shipped as part of this image can be found on [the
image's appropriate Sourcemation
entry](https://www.sourcemation.com).
30 changes: 30 additions & 0 deletions containers/images/ruby-3.4/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# ---------------------------------------------------
# Automated build process for the ruby 3.4 image
# Author: Alex Baranowski
# e-mail: aleksander.baranowski@yahoo.pl
# ---------------------------------------------------

APP="ruby-3.4"

# Updating repository metadata and downloading the latest available version of the application
echo "Checking the latest available version of the $APP"
VERSION=$(git ls-remote --refs --tags https://github.com/ruby/ruby.git | grep -o 'v3_4_[0-9]*$' | tr -d 'v' | tr '_' '.' | sort --version-sort --reverse | head -1)

# Exit with an error if the returned version contains anything other than digits and dots
[[ ! $VERSION =~ ^[0-9.]+$ ]] && exit 1

# Now get the SHA256 sum
echo "Fetching and computing SHA256 for ruby-$VERSION"
SHA256_SUM=$(curl -s "https://cache.ruby-lang.org/pub/ruby/3.4/ruby-${VERSION}.tar.xz" | sha256sum | awk '{print $1}')

# Replacing the version number and SHA256 in the Dockerfile
sed -i "s/version=\"[^\"]*\"/version=\"$VERSION\"/" Dockerfile || exit 1
sed -i "s/ENV RUBY_VERSION [0-9.]*/ENV RUBY_VERSION $VERSION/" Dockerfile || exit 1
sed -i "s|ENV RUBY_DOWNLOAD_URL .*|ENV RUBY_DOWNLOAD_URL https://cache.ruby-lang.org/pub/ruby/3.4/ruby-${VERSION}.tar.xz|" Dockerfile || exit 1
sed -i "s/ENV RUBY_DOWNLOAD_SHA256 [a-f0-9]*/ENV RUBY_DOWNLOAD_SHA256 $SHA256_SUM/" Dockerfile || exit 1

# Replacing the version number in README.md
sed -i "s/APP_VERSION=\"[^\"]*\"/APP_VERSION=\"$VERSION\"/" README.md || exit 1

echo "Finished setting up the $APP $VERSION image"
Loading
Loading