Skip to content

Commit

Permalink
Add noble images for ruby 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorific committed Dec 31, 2024
1 parent a8af6df commit 26b6f97
Show file tree
Hide file tree
Showing 7 changed files with 303 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ jobs:
pulumi/pulumi-python: 'pulumi/pulumi-python/**'
redis/7.2/jammy: 'redis/7.2/jammy/**'
ruby/3.1/jammy: 'ruby/3.1/jammy/**'
ruby/3.1/noble: 'ruby/3.1/noble/**'
ruby/3.1/slim-jammy: 'ruby/3.1/slim-jammy/**'
ruby/3.1/slim-noble: 'ruby/3.1/slim-noble/**'
ruby/3.2/jammy: 'ruby/3.2/jammy/**'
ruby/3.2/slim-jammy: 'ruby/3.2/slim-jammy/**'
ruby/3.3/jammy: 'ruby/3.3/jammy/**'
Expand Down
20 changes: 8 additions & 12 deletions ruby/3.1/jammy/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
ARG BASE_IMAGE=docker.io/polymathrobotics/buildpack-deps:jammy
FROM $BASE_IMAGE

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

ENV LANG C.UTF-8
ENV LANG=C.UTF-8

# https://www.ruby-lang.org/en/news/2024/05/29/ruby-3-1-6-released/
ENV RUBY_VERSION 3.1.6
ENV RUBY_DOWNLOAD_URL https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.6.tar.xz
ENV RUBY_DOWNLOAD_SHA256 597bd1849f252d8a6863cb5d38014ac54152b508c36dca156f6356a9e63c6102
ENV RUBY_VERSION=3.1.6
ENV RUBY_DOWNLOAD_URL=https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.6.tar.xz
ENV RUBY_DOWNLOAD_SHA256=597bd1849f252d8a6863cb5d38014ac54152b508c36dca156f6356a9e63c6102

# 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
Expand Down Expand Up @@ -63,10 +60,9 @@ RUN set -eux; \
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark > /dev/null; \
find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1 || so == "/usr/local/src/ruby/libruby.so.3.1") { next }; gsub("^/(usr/)?", "", so); if (so != "src/ruby/libruby.so.3.1") printf "*%s\n", so }' \
| sort -u \
| grep -vE '^/usr/local/lib/' \
| xargs -r sh -c "dpkg-query --search || true" \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
Expand Down
91 changes: 91 additions & 0 deletions ruby/3.1/noble/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# syntax=docker/dockerfile:1
ARG BASE_IMAGE=docker.io/polymathrobotics/buildpack-deps:noble
FROM $BASE_IMAGE

# 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/2024/05/29/ruby-3-1-6-released/
ENV RUBY_VERSION=3.1.6
ENV RUBY_DOWNLOAD_URL=https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.6.tar.xz
ENV RUBY_DOWNLOAD_SHA256=597bd1849f252d8a6863cb5d38014ac54152b508c36dca156f6356a9e63c6102

# 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
# hadolint ignore=DL3003,SC2086,DL4006
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/*; \
\
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 \
; \
make -j "$(nproc)"; \
make install; \
\
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 || so == "/usr/local/src/ruby/libruby.so.3.1") { next }; gsub("^/(usr/)?", "", so); if (so != "src/ruby/libruby.so.3.1") printf "*%s\n", so }' \
| sort -u \
| xargs -r dpkg-query --search \
| grep -v "diversion by" \
| 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" ]
38 changes: 38 additions & 0 deletions ruby/3.1/noble/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
variable "TAG_PREFIX" {
default = "docker.io/polymathrobotics/ruby"
}

variable "VERSION" {
default = "3.1.6"
}

# There's no darwin-based Docker, so if we're running on macOS, change the platform to linux
variable "LOCAL_PLATFORM" {
default = regex_replace("${BAKE_LOCAL_PLATFORM}", "^(darwin)", "linux")
}

target "_common" {
dockerfile = "Containerfile"
tags = [
"${TAG_PREFIX}:${VERSION}-noble",
"${TAG_PREFIX}:${join(".", slice(split(".", "${VERSION}"), 0, 2))}-noble",
]
labels = {
"org.opencontainers.image.source" = "https://github.com/polymathrobotics/oci"
"org.opencontainers.image.licenses" = "Apache-2.0"
"org.opencontainers.image.description" = "Ruby is a dynamic, reflective, object-oriented, general-purpose, open-source programming language."
"org.opencontainers.image.title" = "${TAG_PREFIX}"
"org.opencontainers.image.created" = "${timestamp()}"
"dev.polymathrobotics.image.readme-filepath" = "ruby/README.md"
}
}

target "local" {
inherits = ["_common"]
platforms = ["${LOCAL_PLATFORM}"]
}

target "default" {
inherits = ["_common"]
platforms = ["linux/amd64", "linux/arm64/v8"]
}
19 changes: 8 additions & 11 deletions ruby/3.1/slim-jammy/Containerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
ARG BASE_IMAGE=docker.io/ubuntu:jammy-20240808
ARG BASE_IMAGE=docker.io/ubuntu:jammy-20240911.1
FROM $BASE_IMAGE

RUN set -eux; \
Expand All @@ -16,20 +16,17 @@ RUN set -eux; \
; \
rm -rf /var/lib/apt/lists/*

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

ENV LANG C.UTF-8
ENV LANG=C.UTF-8

# https://www.ruby-lang.org/en/news/2024/05/29/ruby-3-1-6-released/
ENV RUBY_VERSION 3.1.6
ENV RUBY_DOWNLOAD_URL https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.6.tar.xz
ENV RUBY_DOWNLOAD_SHA256 597bd1849f252d8a6863cb5d38014ac54152b508c36dca156f6356a9e63c6102
ENV RUBY_VERSION=3.1.6
ENV RUBY_DOWNLOAD_URL=https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.6.tar.xz
ENV RUBY_DOWNLOAD_SHA256=597bd1849f252d8a6863cb5d38014ac54152b508c36dca156f6356a9e63c6102

# 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
Expand Down Expand Up @@ -90,7 +87,7 @@ RUN set -eux; \
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 }' \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1 || so == "/usr/local/src/ruby/libruby.so.3.1") { next }; gsub("^/(usr/)?", "", so); if (so != "src/ruby/libruby.so.3.1") printf "*%s\n", so }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
Expand Down
118 changes: 118 additions & 0 deletions ruby/3.1/slim-noble/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# syntax=docker/dockerfile:1
ARG BASE_IMAGE=docker.io/ubuntu:noble-20241118.1
FROM $BASE_IMAGE

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
bzip2 \
ca-certificates \
libffi-dev \
libgmp-dev \
libssl-dev \
libyaml-dev \
procps \
zlib1g-dev \
; \
rm -rf /var/lib/apt/lists/*

# 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/2024/05/29/ruby-3-1-6-released/
ENV RUBY_VERSION=3.1.6
ENV RUBY_DOWNLOAD_URL=https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.6.tar.xz
ENV RUBY_DOWNLOAD_SHA256=597bd1849f252d8a6863cb5d38014ac54152b508c36dca156f6356a9e63c6102

# 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
# hadolint ignore=DL3003,SC2086,DL4006
RUN set -eux; \
\
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
bison \
dpkg-dev \
libgdbm-dev \
ruby \
autoconf \
g++ \
gcc \
libbz2-dev \
libgdbm-compat-dev \
libglib2.0-dev \
libncurses-dev \
libreadline-dev \
libxml2-dev \
libxslt-dev \
make \
wget \
xz-utils \
; \
rm -rf /var/lib/apt/lists/*; \
\
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 \
; \
make -j "$(nproc)"; \
make install; \
\
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 || so == "/usr/local/src/ruby/libruby.so.3.1") { next }; gsub("^/(usr/)?", "", so); if (so != "src/ruby/libruby.so.3.1") printf "*%s\n", so }' \
| sort -u \
| xargs -r dpkg-query --search \
| grep -v "diversion by" \
| 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" ]
38 changes: 38 additions & 0 deletions ruby/3.1/slim-noble/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
variable "TAG_PREFIX" {
default = "docker.io/polymathrobotics/ruby"
}

variable "VERSION" {
default = "3.1.6"
}

# There's no darwin-based Docker, so if we're running on macOS, change the platform to linux
variable "LOCAL_PLATFORM" {
default = regex_replace("${BAKE_LOCAL_PLATFORM}", "^(darwin)", "linux")
}

target "_common" {
dockerfile = "Containerfile"
tags = [
"${TAG_PREFIX}:${VERSION}-slim-noble",
"${TAG_PREFIX}:${join(".", slice(split(".", "${VERSION}"), 0, 2))}-slim-noble",
]
labels = {
"org.opencontainers.image.source" = "https://github.com/polymathrobotics/oci"
"org.opencontainers.image.licenses" = "Apache-2.0"
"org.opencontainers.image.description" = "Ruby is a dynamic, reflective, object-oriented, general-purpose, open-source programming language."
"org.opencontainers.image.title" = "${TAG_PREFIX}"
"org.opencontainers.image.created" = "${timestamp()}"
"dev.polymathrobotics.image.readme-filepath" = "ruby/README.md"
}
}

target "local" {
inherits = ["_common"]
platforms = ["${LOCAL_PLATFORM}"]
}

target "default" {
inherits = ["_common"]
platforms = ["linux/amd64", "linux/arm64/v8"]
}

0 comments on commit 26b6f97

Please sign in to comment.