Skip to content

Commit 314220e

Browse files
byrootrafaelfranca
authored andcommitted
Merge pull request #49525 from abhaynikam/fix-app-generated-dockerfile-to-use-correct-ruby-version
Ensures the Rails generated Dockerfile uses correct ruby version and matches Gemfile
1 parent 1f1710d commit 314220e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

railties/lib/rails/generators/rails/app/templates/Dockerfile.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# syntax = docker/dockerfile:1
22

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

77
# Rails app lives here

railties/test/generators/app_generator_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,9 @@ def test_inclusion_of_ruby_version
955955
assert_file "Gemfile" do |content|
956956
assert_match(/ruby "#{Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") ? Gem.ruby_version : RUBY_VERSION}"/, content)
957957
end
958+
assert_file "Dockerfile" do |content|
959+
assert_match(/ARG RUBY_VERSION=#{Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") ? Gem.ruby_version : RUBY_VERSION}/, content)
960+
end
958961
assert_file ".ruby-version" do |content|
959962
if ENV["RBENV_VERSION"]
960963
assert_match(/#{ENV["RBENV_VERSION"]}/, content)

0 commit comments

Comments
 (0)