Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated deploy.yml template to fetch the Ruby version automatically #1105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

igor-alexandrov
Copy link
Contributor

Rails default Dockerfile requires the RUBY_VERSION argument. Kamal should have an example how to read the Ruby version automatically.

@igor-alexandrov igor-alexandrov marked this pull request as ready for review October 12, 2024 17:31
@kylekeesling
Copy link

Hi Igor, great addition here! I ran into an additional step I had to work through to get this rolling and thought I'd share in case anyone else is in the same boat.

I had to make an additional change to my Dockerfile that copied the .ruby-version file over with the Gemfile so that it's available for bundler:

# Dockerfile

# Install application gems
COPY .ruby-version Gemfile Gemfile.lock ./
RUN bundle install && .....

This is because I use the following directive in my Gemfile:

# Gemfile

source "https://rubygems.org"
ruby file: ".ruby-version"

@igor-alexandrov
Copy link
Contributor Author

Yes, this probably should be added to the Rails default Dockerfile.

@kylekeesling
Copy link

Happy to take a crack at that if you think it’d be useful.

@kylekeesling
Copy link

I opened a PR as a jumping off point here: rails/rails#53369

@kylekeesling
Copy link

Rejected for now since the use of ruby file: .ruby-version is discouraged as a default by Rails. More info here:
rails/rails#51089

@igor-alexandrov
Copy link
Contributor Author

I've always been wondering why do we need to duplicate the version of the interpreter in the Gemfile while we have it in the .ruby-version? The answer is pretty simple – we don't need to duplicate.

@fidalgo
Copy link

fidalgo commented Oct 19, 2024

Just dropping this, despite agreeing we should have a common place to specify the ruby version, .ruby-version is not the only way to do it:
cat .tool-versions

ruby 3.3.3
nodejs 20.13.1

Gemfile already supports, so we can have:
ruby file: ".tool-versions"

So should we aim for the same? Here's the bundler implementation: https://github.com/rubygems/rubygems/blob/v3.5.22/bundler/lib/bundler/ruby_dsl.rb#L43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants