phusion / passenger-docker

Docker base images for Ruby, Python, Node.js and Meteor web apps
MIT License
2.78k stars 408 forks source link

Unreliable default RVM Ruby version in customizable images #299

Closed tf closed 3 years ago

tf commented 4 years ago

Building a Docker image based on phusion/passenger-customizable, I see different Ruby versions picked as default depending on the build environment:

# Dockerfile
FROM phusion/passenger-customizable:1.0.9
RUN /pd_build/ruby-2.5.7.sh

The resulting image contains Ruby 2.6 and Ruby 2.5 (which is not in line with what the readme says: #298) . Building the image locally results in Ruby 2.6 being selected as default RVM Ruby version. Building the image in CI, Ruby 2.5 is selected. As part of the RUN step, I see different outputs:

+ /pd_build/ruby_support/finalize.sh
+ Setting ruby-2.6.5 as default RVM Ruby
+ /pd_build/ruby_support/finalize.sh
+ Setting ruby-2.5.7 as default RVM Ruby

Digging deeper, I see that the order of Ruby versions reported by rvm list strings appears to depend on the environment. If I extend my Dockerfile

# Dockerfile
FROM phusion/passenger-customizable:1.0.9
RUN /pd_build/ruby-2.5.*.sh
RUN bash -lc 'rvm list strings'

I see that in CI the order of the output is different:

ruby-2.5.7
ruby-2.6.5

ruby_support/finalize.sh appears to depend on this order:

https://github.com/phusion/passenger-docker/blob/8f6bb02e93b4b39f0f3a43381e88c3f241a52186/image/ruby_support/finalize.sh#L20-L31

It sets the first listed Ruby as default. As a workaround, I can explicitly specify the desired default version in my Dockerfile. The current default behavior appears to be fragile, though.

tim-millar commented 4 years ago

how are you explicitly setting the default version, @tf?

tf commented 4 years ago

I have the following line in my Dockerfile:

RUN /pd_build/ruby-2.5.*.sh && bash -lc 'rvm --default use 2.5'
tim-millar commented 4 years ago
RUN bash -lc 'rvm --default use ruby-2.6.3'

seems to have done the trick for me (after installing that version of ruby).

tf commented 3 years ago

Might be fixed on master since https://github.com/phusion/passenger-docker/commit/5cba6c7becd5979fadde50878892513ae8293646#diff-8fdcb365e86ae9f412339d9d2f8202a58b522430916ee6956503f9c17a6be7dd changed the logic to not expect the newest Ruby to be the first Ruby in rvm list strings at least when detecting installed Ruby versions

https://github.com/phusion/passenger-docker/commit/e6a022b3454863c53dabd20b28ba902a0e8a4eea#diff-8fdcb365e86ae9f412339d9d2f8202a58b522430916ee6956503f9c17a6be7dd now also made this change for actually selecting the default version.

CamJN commented 3 years ago

should be fixed now