5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/dockerfile-rails/scanner.rb', line 5
def scan_rails_app
@gemfile = []
@git = false
if File.exist? "Gemfile.lock"
parser = Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock"))
@gemfile += parser.specs.map { |spec, version| spec.name }
@git ||= ENV["RAILS_ENV"] != "test" && parser.specs.any? do |spec|
spec.source.instance_of? Bundler::Source::Git
end
if RUBY_VERSION == "3.3.3" && @gemfile.include?("net-pop")
@netpopbug = parser.specs.find { |spec| spec.name == "net-pop" }.dependencies.empty?
end
end
if File.exist? "Gemfile"
begin
gemfile_definition = Bundler::Definition.build("Gemfile", nil, [])
@gemfile += gemfile_definition.dependencies.map(&:name)
unless ENV["RAILS_ENV"] == "test"
@git = !gemfile_definition.spec_git_paths.empty?
end
rescue => error
STDERR.puts error.message
end
end
@anycable = @gemfile.include? "anycable-rails"
@vips = @gemfile.include? "ruby-vips"
@bootstrap = @gemfile.include? "bootstrap"
@puppeteer = @gemfile.include? "puppeteer"
@bootsnap = @gemfile.include? "bootsnap"
database = YAML.load_file("config/database.yml", aliases: true).
dig("production", "adapter") rescue nil
if database == "sqlite3"
@sqlite3 = true
elsif database == "postgresql"
@postgresql = true
elsif (database == "mysql") || (database == "mysql2") || (database == "trilogy")
@mysql = true
elsif database == "sqlserver"
@sqlserver = true
end
@sqlite3 = true if @gemfile.include? "sqlite3"
@postgresql = true if @gemfile.include? "pg"
@mysql = true if @gemfile.include?("mysql2") || using_trilogy?
@sqlserver = true if @gemfile.include?("activerecord-sqlserver-adapter")
@package_json = []
if File.exist? "package.json"
@package_json += JSON.load_file("package.json")["dependencies"].keys rescue []
end
@puppeteer ||= @package_json.include? "puppeteer"
@cable = ! Dir["app/channels/*.rb"].empty?
if @cable
@redis_cable = true
if (YAML.load_file("config/cable.yml").dig("production", "adapter") rescue "").include? "any_cable"
@anycable = true
end
end
if (IO.read("config/environments/production.rb") =~ /redis/i rescue false)
@redis_cache = true
end
@redis = @redis_cable || @redis_cache
end
|