Skip to content

Commit

Permalink
Merge pull request #369 from ajhodgson/ajhodgson/speed-buildall2
Browse files Browse the repository at this point in the history
Compile C rubies from source, use 3.2.2 by default, and speed build_all by caching self-built rubies
  • Loading branch information
CamJN authored Jun 26, 2023
2 parents a46604b + c9a1424 commit de5b806
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 46 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ ruby*_image
jruby*_image
nodejs_image
full_image
base_image
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## not released
* Compile all CRuby versions from source to ensure uniformity and YJIT capability in versions 3.1+
* Use Ruby 3.2.x by default
* Upgraded to JRuby 9.3.10.0
* Upgraded to JRuby 9.4.3.0

Expand Down
55 changes: 32 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ else
REGISTRY = docker.io
endif
NAME = $(REGISTRY)/phusion/passenger

VERSION = 2.5.1

# Extra flags for docker build, usable via environment variable.
# Example: `export EXTRA_BUILD_FLAGS=--no-cache; make build_all`
EXTRA_BUILD_FLAGS?=
Expand All @@ -13,15 +15,18 @@ EXTRA_BUILD_FLAGS?=

all: build_all

# waits are to ensure that we only compile each version of ruby once per arch
build_all: \
build_customizable \
.WAIT \
build_jruby93 \
build_jruby94 \
build_nodejs \
build_ruby27 \
build_ruby30 \
build_ruby31 \
build_ruby32 \
build_jruby93 \
build_jruby94 \
build_nodejs \
.WAIT \
build_full

labels:
Expand Down Expand Up @@ -67,73 +72,76 @@ pull:
build_base:
docker rmi $(NAME)-base:current-amd64 || true
docker rmi $(NAME)-base:current-arm64 || true
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) -t $(NAME)-base:current-amd64 -f image/Dockerfile.base image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) -t $(NAME)-base:current-arm64 -f image/Dockerfile.base image --no-cache
rm -rf base_image
cp -pR image base_image
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg ARCH=amd64 -t $(NAME)-base:current-amd64 -f image/Dockerfile.base base_image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg ARCH=arm64 -t $(NAME)-base:current-arm64 -f image/Dockerfile.base base_image --no-cache
rm -rf base_image

# Docker doesn't support sharing files between different Dockerfiles. -_-
# So we copy things around.

build_customizable: build_base
rm -rf customizable_image
cp -pR image customizable_image
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-customizable:$(VERSION)-amd64 --rm customizable_image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-customizable:$(VERSION)-arm64 --rm customizable_image --no-cache
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-customizable:$(VERSION)-amd64 --rm customizable_image
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-customizable:$(VERSION)-arm64 --rm customizable_image

build_ruby27: build_base
rm -rf ruby27_image
cp -pR image ruby27_image
echo ruby27=1 >> ruby27_image/buildconfig
echo final=1 >> ruby27_image/buildconfig
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-ruby27:$(VERSION)-amd64 --rm ruby27_image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-ruby27:$(VERSION)-arm64 --rm ruby27_image --no-cache
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-ruby27:$(VERSION)-amd64 --rm ruby27_image
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-ruby27:$(VERSION)-arm64 --rm ruby27_image

build_ruby30: build_base
rm -rf ruby30_image
cp -pR image ruby30_image
echo ruby30=1 >> ruby30_image/buildconfig
echo final=1 >> ruby30_image/buildconfig
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-ruby30:$(VERSION)-amd64 --rm ruby30_image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-ruby30:$(VERSION)-arm64 --rm ruby30_image --no-cache
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-ruby30:$(VERSION)-amd64 --rm ruby30_image
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-ruby30:$(VERSION)-arm64 --rm ruby30_image

build_ruby31: build_base
rm -rf ruby31_image
cp -pR image ruby31_image
echo ruby31=1 >> ruby31_image/buildconfig
echo final=1 >> ruby31_image/buildconfig
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-ruby31:$(VERSION)-amd64 --rm ruby31_image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-ruby31:$(VERSION)-arm64 --rm ruby31_image --no-cache
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-ruby31:$(VERSION)-amd64 --rm ruby31_image
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-ruby31:$(VERSION)-arm64 --rm ruby31_image

build_ruby32: build_base
rm -rf ruby32_image
cp -pR image ruby32_image
echo ruby32=1 >> ruby32_image/buildconfig
echo final=1 >> ruby32_image/buildconfig
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-ruby32:$(VERSION)-amd64 --rm ruby32_image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-ruby32:$(VERSION)-arm64 --rm ruby32_image --no-cache
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-ruby32:$(VERSION)-amd64 --rm ruby32_image
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-ruby32:$(VERSION)-arm64 --rm ruby32_image

build_jruby93: build_base
rm -rf jruby93_image
cp -pR image jruby93_image
echo jruby93=1 >> jruby93_image/buildconfig
echo final=1 >> jruby93_image/buildconfig
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-jruby93:$(VERSION)-amd64 --rm jruby93_image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-jruby93:$(VERSION)-arm64 --rm jruby93_image --no-cache
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-jruby93:$(VERSION)-amd64 --rm jruby93_image
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-jruby93:$(VERSION)-arm64 --rm jruby93_image

build_jruby94: build_base
rm -rf jruby94_image
cp -pR image jruby94_image
echo jruby94=1 >> jruby94_image/buildconfig
echo final=1 >> jruby94_image/buildconfig
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-jruby94:$(VERSION)-amd64 --rm jruby94_image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-jruby94:$(VERSION)-arm64 --rm jruby94_image --no-cache
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-jruby94:$(VERSION)-amd64 --rm jruby94_image
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-jruby94:$(VERSION)-arm64 --rm jruby94_image

build_nodejs: build_base
rm -rf nodejs_image
cp -pR image nodejs_image
echo nodejs=1 >> nodejs_image/buildconfig
echo final=1 >> nodejs_image/buildconfig
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-nodejs:$(VERSION)-amd64 --rm nodejs_image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-nodejs:$(VERSION)-arm64 --rm nodejs_image --no-cache
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-nodejs:$(VERSION)-amd64 --rm nodejs_image
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-nodejs:$(VERSION)-arm64 --rm nodejs_image

build_full: build_base
rm -rf full_image
Expand All @@ -149,8 +157,8 @@ build_full: build_base
echo redis=1 >> full_image/buildconfig
echo memcached=1 >> full_image/buildconfig
echo final=1 >> full_image/buildconfig
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-full:$(VERSION)-amd64 --rm full_image --no-cache
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-full:$(VERSION)-arm64 --rm full_image --no-cache
docker buildx build --progress=plain --platform linux/amd64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=amd64 -t $(NAME)-full:$(VERSION)-amd64 --rm full_image
docker buildx build --progress=plain --platform linux/arm64 $(EXTRA_BUILD_FLAGS) --build-arg REGISTRY=$(REGISTRY) --build-arg ARCH=arm64 -t $(NAME)-full:$(VERSION)-arm64 --rm full_image

tag_latest: tag_latest_customizable tag_latest_ruby27 tag_latest_ruby30 tag_latest_ruby31 tag_latest_ruby32 tag_latest_jruby93 tag_latest_jruby94 tag_latest_nodejs tag_latest_full

Expand Down Expand Up @@ -333,6 +341,7 @@ release_ruby27: push_ruby27
docker manifest push $(NAME)-ruby27:latest

clean:
rm -rf base_image
rm -rf customizable_image
rm -rf ruby27_image
rm -rf ruby30_image
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Language support:

* Ruby 2.7.8, 3.0.6, 3.1.4, 3.2.2 and JRuby 9.3.10.0 and 9.4.3.0.
* RVM is used to manage Ruby versions. [Why RVM?](#why_rvm)
* 3.1.4 is configured as the default.
* 3.2.2 is configured as the default.
* JRuby is installed from source, but we register an APT entry for it.
* JRuby uses OpenJDK 17.
* Python 2.7 and Python 3.8.
Expand Down
5 changes: 4 additions & 1 deletion image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# syntax=docker/dockerfile:1.2
ARG ARCH
ARG REGISTRY
FROM $REGISTRY/phusion/passenger-base:current-$ARCH
MAINTAINER Phusion <info@phusion.nl>

ADD . /pd_build

RUN /pd_build/install_image.sh
ARG ARCH
RUN --mount=type=cache,target=/rvm_cache \
/usr/bin/nice /pd_build/install_image.sh

CMD ["/sbin/my_init"]
EXPOSE 80 443
6 changes: 5 additions & 1 deletion image/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# syntax=docker/dockerfile:1.2
FROM phusion/baseimage:master
MAINTAINER Phusion <info@phusion.nl>

ADD . /pd_build

RUN /pd_build/install_base.sh && \
ARG ARCH
RUN --mount=type=cache,target=/rvm_cache \
rm -rf "/rvm_cache/${ARCH}" && \
/usr/bin/nice /pd_build/install_base.sh && \
rm -rf /pd_build
2 changes: 1 addition & 1 deletion image/finalize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [[ -e /usr/local/rvm ]]; then
run /usr/local/rvm/bin/rvm cleanup all
fi

run apt-get remove -y autoconf automake
run apt-get remove -y autoconf automake rustc
run apt-get autoremove -y

if [[ "$final" = 1 ]]; then
Expand Down
1 change: 1 addition & 0 deletions image/install_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ run /pd_build/enable_repos.sh
run /pd_build/update_baseimage.sh
run /pd_build/prepare.sh
run /pd_build/utilities.sh
run /pd_build/ruby_support/prepare.sh

cleanup_apt
1 change: 0 additions & 1 deletion image/jruby-9.3.10.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ run minimal_apt_get_install openjdk-17-jre-headless
run dpkg-reconfigure ca-certificates-java

header "Installing $RVM_ID"
run /pd_build/ruby_support/prepare.sh
run /usr/local/rvm/bin/rvm install $RVM_ID
run /usr/local/rvm/bin/rvm-exec $RVM_ID@global gem install $DEFAULT_RUBY_GEMS --no-document
run create_rvm_wrapper_script jruby9.3 $RVM_ID ruby
Expand Down
1 change: 0 additions & 1 deletion image/jruby-9.4.3.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ run minimal_apt_get_install openjdk-17-jre-headless
run dpkg-reconfigure ca-certificates-java

header "Installing $RVM_ID"
run /pd_build/ruby_support/prepare.sh
run /usr/local/rvm/bin/rvm install $RVM_ID
run /usr/local/rvm/bin/rvm-exec $RVM_ID@global gem install $DEFAULT_RUBY_GEMS --no-document
run create_rvm_wrapper_script jruby9.4 $RVM_ID ruby
Expand Down
25 changes: 19 additions & 6 deletions image/nginx-passenger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@ source /etc/environment

header "Installing Phusion Passenger..."

## Phusion Passenger requires Ruby. Install it through RVM, not APT,
## so that the -customizable variant cannot end up having Ruby installed
## from both APT and RVM.
## Phusion Passenger requires Ruby. Install if this image does not already have one.
## Install it through RVM, not APT, so that the -customizable variant cannot end up
## having Ruby installed from both APT and RVM.
if [[ ! -e /usr/bin/ruby ]]; then
run /pd_build/ruby_support/prepare.sh
run /usr/local/rvm/bin/rvm install ruby-3.1.4
RVM_ID="ruby-3.2.2"

run mkdir -p "/rvm_cache/${ARCH}"
if [[ -e "/rvm_cache/${ARCH}/${RVM_ID}.tar.bz2" ]]; then
# use cached ruby if present
run /usr/local/rvm/bin/rvm mount "/rvm_cache/${ARCH}/${RVM_ID}.tar.bz2"
else
# otherwise build one
run minimal_apt_get_install rustc # For compiling Ruby with YJIT
MAKEFLAGS=-j$(nproc) run /usr/local/rvm/bin/rvm install $RVM_ID --disable-cache || ( cat /usr/local/rvm/log/*${RVM_ID}*/*.log && false )
run cd "/rvm_cache/${ARCH}"
run /usr/local/rvm/bin/rvm prepare "${RVM_ID}"
run cd /
fi

# Make passenger_system_ruby work.
run create_rvm_wrapper_script ruby3.1 ruby-3.1.4 ruby
run create_rvm_wrapper_script ruby3.2 ruby-3.2.2 ruby
run /pd_build/ruby_support/finalize.sh
fi

Expand Down
15 changes: 13 additions & 2 deletions image/ruby-2.7.8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@ source /pd_build/buildconfig
RVM_ID=$(basename "$0" | sed 's/.sh$//')

header "Installing $RVM_ID"
run /pd_build/ruby_support/prepare.sh
run /usr/local/rvm/bin/rvm install $RVM_ID || ( cat /usr/local/rvm/log/*${RVM_ID}*/*.log && false )

run mkdir -p "/rvm_cache/${ARCH}"
if [[ -e "/rvm_cache/${ARCH}/${RVM_ID}.tar.bz2" ]]; then
# use cached ruby if present
run /usr/local/rvm/bin/rvm mount "/rvm_cache/${ARCH}/${RVM_ID}.tar.bz2"
else
# otherwise build one
MAKEFLAGS=-j$(nproc) run /usr/local/rvm/bin/rvm install $RVM_ID --disable-cache || ( cat /usr/local/rvm/log/*${RVM_ID}*/*.log && false )
run cd "/rvm_cache/${ARCH}"
run /usr/local/rvm/bin/rvm prepare "${RVM_ID}"
run cd /
fi

run /usr/local/rvm/bin/rvm-exec $RVM_ID@global gem install $DEFAULT_RUBY_GEMS --no-document
# Make passenger_system_ruby work.
run create_rvm_wrapper_script ruby2.7 $RVM_ID ruby
Expand Down
15 changes: 13 additions & 2 deletions image/ruby-3.0.6.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@ source /pd_build/buildconfig
RVM_ID=$(basename "$0" | sed 's/.sh$//')

header "Installing $RVM_ID"
run /pd_build/ruby_support/prepare.sh
run /usr/local/rvm/bin/rvm install $RVM_ID || ( cat /usr/local/rvm/log/*${RVM_ID}*/*.log && false )

run mkdir -p "/rvm_cache/${ARCH}"
if [[ -e "/rvm_cache/${ARCH}/${RVM_ID}.tar.bz2" ]]; then
# use cached ruby if present
run /usr/local/rvm/bin/rvm mount "/rvm_cache/${ARCH}/${RVM_ID}.tar.bz2"
else
# otherwise build one
MAKEFLAGS=-j$(nproc) run /usr/local/rvm/bin/rvm install $RVM_ID --disable-cache || ( cat /usr/local/rvm/log/*${RVM_ID}*/*.log && false )
run cd "/rvm_cache/${ARCH}"
run /usr/local/rvm/bin/rvm prepare "${RVM_ID}"
run cd /
fi

run /usr/local/rvm/bin/rvm-exec $RVM_ID@global gem install $DEFAULT_RUBY_GEMS --no-document
# Make passenger_system_ruby work.
run create_rvm_wrapper_script ruby3.0 $RVM_ID ruby
Expand Down
16 changes: 14 additions & 2 deletions image/ruby-3.1.4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ source /pd_build/buildconfig
RVM_ID=$(basename "$0" | sed 's/.sh$//')

header "Installing $RVM_ID"
run /pd_build/ruby_support/prepare.sh
run /usr/local/rvm/bin/rvm install $RVM_ID || ( cat /usr/local/rvm/log/*${RVM_ID}*/*.log && false )

run mkdir -p "/rvm_cache/${ARCH}"
if [[ -e "/rvm_cache/${ARCH}/${RVM_ID}.tar.bz2" ]]; then
# use cached ruby if present
run /usr/local/rvm/bin/rvm mount "/rvm_cache/${ARCH}/${RVM_ID}.tar.bz2"
else
# otherwise build one
run minimal_apt_get_install rustc # For compiling Ruby with YJIT
MAKEFLAGS=-j$(nproc) run /usr/local/rvm/bin/rvm install $RVM_ID --disable-cache || ( cat /usr/local/rvm/log/*${RVM_ID}*/*.log && false )
run cd "/rvm_cache/${ARCH}"
run /usr/local/rvm/bin/rvm prepare "${RVM_ID}"
run cd /
fi

run /usr/local/rvm/bin/rvm-exec $RVM_ID@global gem install $DEFAULT_RUBY_GEMS --no-document
# Make passenger_system_ruby work.
run create_rvm_wrapper_script ruby3.1 $RVM_ID ruby
Expand Down
16 changes: 14 additions & 2 deletions image/ruby-3.2.2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ source /pd_build/buildconfig
RVM_ID=$(basename "$0" | sed 's/.sh$//')

header "Installing $RVM_ID"
run /pd_build/ruby_support/prepare.sh
run /usr/local/rvm/bin/rvm install $RVM_ID || ( cat /usr/local/rvm/log/*${RVM_ID}*/*.log && false )

run mkdir -p "/rvm_cache/${ARCH}"
if [[ -e "/rvm_cache/${ARCH}/${RVM_ID}.tar.bz2" ]]; then
# use cached ruby if present
run /usr/local/rvm/bin/rvm mount "/rvm_cache/${ARCH}/${RVM_ID}.tar.bz2"
else
# otherwise build one
run minimal_apt_get_install rustc # For compiling Ruby with YJIT
MAKEFLAGS=-j$(nproc) run /usr/local/rvm/bin/rvm install $RVM_ID --disable-cache || ( cat /usr/local/rvm/log/*${RVM_ID}*/*.log && false )
run cd "/rvm_cache/${ARCH}"
run /usr/local/rvm/bin/rvm prepare "${RVM_ID}"
run cd /
fi

run /usr/local/rvm/bin/rvm-exec $RVM_ID@global gem install $DEFAULT_RUBY_GEMS --no-document
# Make passenger_system_ruby work.
run create_rvm_wrapper_script ruby3.2 $RVM_ID ruby
Expand Down
6 changes: 3 additions & 3 deletions image/ruby_support/finalize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ function set_rvm_default()
}

known_rubies=`/usr/local/rvm/bin/rvm list strings`
if [[ "$known_rubies" =~ ruby-3\.1 ]]; then
set_rvm_default ruby-3\.1
elif [[ "$known_rubies" =~ ruby-3\.2 ]]; then
if [[ "$known_rubies" =~ ruby-3\.2 ]]; then
set_rvm_default ruby-3\.2
elif [[ "$known_rubies" =~ ruby-3\.1 ]]; then
set_rvm_default ruby-3\.1
elif [[ "$known_rubies" =~ ruby-3\.0 ]]; then
set_rvm_default ruby-3\.0
elif [[ "$known_rubies" =~ ruby-2\.7 ]]; then
Expand Down

0 comments on commit de5b806

Please sign in to comment.