fly-apps / dockerfile-rails

Provides a Rails generator to produce Dockerfiles and related files.
MIT License
474 stars 38 forks source link

Copy .ruby-version file to Docker #77

Closed luizkowalski closed 9 months ago

luizkowalski commented 9 months ago

Fixes #76

luizkowalski commented 9 months ago

I can't see exactly the failure, and locally the tests are passing (individually)

rubys commented 9 months ago
image
luizkowalski commented 9 months ago

Pushed the missing change, thanks!

rubys commented 9 months ago

I'm not enthusiastic about copying a file because it might be referenced by the Gemfile. By default, new Rails 7.1 applications will have a .ruby-version file but it won't be referenced by the Gemfile.

Perhaps add something along the lines of && IO.read('Gemfile').include?('.ruby-version') to ruby_version_exists?

rubys commented 9 months ago

Just to be clear: I'm not seeking perfection. If you were to pick a new Rails project at random, it likely will have a .ruby-version file but not referenced in the Gemfile. If the Gemfile itself contains the string ".ruby-version" it likely references that file, but only a full fledged parser would be able to determine if it actually does.

luizkowalski commented 9 months ago

That actually makes sense, since, IIRC, this file is ignored by default.

I will amend the PR

edit: amended. I don't think we need actually to check for the file presence anymore since if the Gemfile references it, it HAS to exist, otherwise the application won't even boot

bradgessler commented 8 months ago

For posterity, bundler is including a mechanism to read the .ruby-version from the Gemfile. It looks like this:

ruby file: ".ruby-version" 

PR at https://github.com/rubygems/rubygems/pull/6876