Skip to content

Commit

Permalink
Merge pull request #49525 from abhaynikam/fix-app-generated-dockerfil…
Browse files Browse the repository at this point in the history
…e-to-use-correct-ruby-version

Ensures the Rails generated Dockerfile uses correct ruby version and matches Gemfile
  • Loading branch information
byroot authored and rafaelfranca committed Oct 11, 2023
1 parent 1f1710d commit 314220e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=<%= Gem.ruby_version %>
ARG RUBY_VERSION=<%= gem_ruby_version %>
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base

# Rails app lives here
Expand Down
3 changes: 3 additions & 0 deletions railties/test/generators/app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,9 @@ def test_inclusion_of_ruby_version
assert_file "Gemfile" do |content|
assert_match(/ruby "#{Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") ? Gem.ruby_version : RUBY_VERSION}"/, content)
end
assert_file "Dockerfile" do |content|
assert_match(/ARG RUBY_VERSION=#{Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") ? Gem.ruby_version : RUBY_VERSION}/, content)
end
assert_file ".ruby-version" do |content|
if ENV["RBENV_VERSION"]
assert_match(/#{ENV["RBENV_VERSION"]}/, content)
Expand Down

0 comments on commit 314220e

Please sign in to comment.