dockerfile-rails 1.6.16 → 1.6.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -0
- data/lib/dockerfile-rails/scanner.rb +12 -0
- data/lib/generators/dockerfile_generator.rb +30 -4
- data/lib/generators/templates/Dockerfile.erb +8 -5
- data/lib/generators/templates/_node_client.erb +1 -1
- data/lib/generators/templates/docker-compose.yml.erb +14 -9
- metadata +3 -4
- data/lib/fly_replay.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '06001664944f094c87433a52a0dcdb69fe820682478861d502923676e26f3c73'
|
4
|
+
data.tar.gz: 4189db8d30eefd52ddf399368f60ea63d940325f143c506304f257b87301b508
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46e8f29cdfdfd8b16feb8392e65c57e4d5a6ea60e2b596273f1c2af43cb4cb88ac969b0a25a2702e35c6c29422e5e557046aa30a1f9c12df3b1b8663d747c159
|
7
|
+
data.tar.gz: 417cd9a7715a2769c9060f9f2438f6486a06362c662a9ea3dc254f2d842b5120e0fea78661eab18f2cc00529b2db5a0a18be5a44055d29e84f7cbca57ceeb009
|
data/Rakefile
CHANGED
@@ -14,6 +14,12 @@ module DockerfileRails
|
|
14
14
|
@git ||= ENV["RAILS_ENV"] != "test" && parser.specs.any? do |spec|
|
15
15
|
spec.source.instance_of? Bundler::Source::Git
|
16
16
|
end
|
17
|
+
|
18
|
+
# determine if the application is affected by the net-pop bug
|
19
|
+
# https://github.com/ruby/ruby/pull/11006#issuecomment-2176562332
|
20
|
+
if RUBY_VERSION == "3.3.3" && @gemfile.include?("net-pop")
|
21
|
+
@netpopbug = parser.specs.find { |spec| spec.name == "net-pop" }.dependencies.empty?
|
22
|
+
end
|
17
23
|
end
|
18
24
|
|
19
25
|
if File.exist? "Gemfile"
|
@@ -86,5 +92,11 @@ module DockerfileRails
|
|
86
92
|
def using_trilogy?
|
87
93
|
@gemfile.include?("trilogy") || @gemfile.include?("activerecord-trilogy-adapter")
|
88
94
|
end
|
95
|
+
|
96
|
+
### patches ###
|
97
|
+
if RUBY_VERSION == "3.3.3"
|
98
|
+
Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock"))
|
99
|
+
|
100
|
+
end
|
89
101
|
end
|
90
102
|
end
|
@@ -402,6 +402,15 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
402
402
|
STDERR.puts "\n" + shell.set_color(message, Thor::Shell::Color::RED, Thor::Shell::Color::BOLD)
|
403
403
|
end
|
404
404
|
|
405
|
+
if @netpopbug && !dockerfile.include?("net-pop")
|
406
|
+
message = "Ruby 3.3.3 net-pop bug detected."
|
407
|
+
STDERR.puts "\n" + shell.set_color(message, Thor::Shell::Color::RED, Thor::Shell::Color::BOLD)
|
408
|
+
STDERR.puts "Please see https://github.com/ruby/ruby/pull/11006"
|
409
|
+
STDERR.puts "Change your Ruby version, or run `bin/rails generate dockerfile`,"
|
410
|
+
STDERR.puts "or add the following to your Dockerfile:"
|
411
|
+
STDERR.puts 'RUN sed -i "/net-pop (0.1.2)/a\ net-protocol" Gemfile.lock'
|
412
|
+
end
|
413
|
+
|
405
414
|
if (options.sqlite3? || @sqlite3) && !dockerfile.include?("DATABASE_URL") && File.exist?("fly.toml")
|
406
415
|
toml = IO.read("fly.toml")
|
407
416
|
if !toml.include?("[[env]]")
|
@@ -508,12 +517,16 @@ private
|
|
508
517
|
options.passenger? or options["max-idle"]
|
509
518
|
end
|
510
519
|
|
520
|
+
def includes_jobs?
|
521
|
+
!(Dir["app/jobs/*.rb"] - ["app/jobs/application_job.rb"]).empty?
|
522
|
+
end
|
523
|
+
|
511
524
|
def using_sidekiq?
|
512
|
-
@gemfile.include?("sidekiq")
|
525
|
+
@gemfile.include?("sidekiq") and includes_jobs?
|
513
526
|
end
|
514
527
|
|
515
528
|
def using_solidq?
|
516
|
-
@gemfile.include?("solid_queue")
|
529
|
+
@gemfile.include?("solid_queue") and includes_jobs?
|
517
530
|
end
|
518
531
|
|
519
532
|
def parallel?
|
@@ -1243,6 +1256,19 @@ private
|
|
1243
1256
|
more
|
1244
1257
|
end
|
1245
1258
|
|
1259
|
+
def compose_web_volumes
|
1260
|
+
volumes = %w[ log storage ]
|
1261
|
+
|
1262
|
+
if deploy_database == "sqlite3"
|
1263
|
+
database = YAML.load_file("config/database.yml", aliases: true).dig("production", "database")
|
1264
|
+
if database && database =~ /^\w/
|
1265
|
+
volumes << File.dirname(database)
|
1266
|
+
end
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
volumes.uniq.sort
|
1270
|
+
end
|
1271
|
+
|
1246
1272
|
def max_idle
|
1247
1273
|
option = options["max-idle"]
|
1248
1274
|
|
@@ -1394,10 +1420,10 @@ private
|
|
1394
1420
|
"kb" => 1000,
|
1395
1421
|
"mib" => 1048576,
|
1396
1422
|
"m" => 1048576,
|
1397
|
-
"mb" =>
|
1423
|
+
"mb" => 1000000,
|
1398
1424
|
"gib" => 1073741824,
|
1399
1425
|
"g" => 1073741824,
|
1400
|
-
"gb" =>
|
1426
|
+
"gb" => 1000000000,
|
1401
1427
|
}
|
1402
1428
|
|
1403
1429
|
pattern = Regexp.new("^(\\d+)(#{suffixes.keys.join('|')})?$", "i")
|
@@ -8,9 +8,9 @@ ARG RUBY_VERSION=<%= RUBY_VERSION %>
|
|
8
8
|
|
9
9
|
<% end -%>
|
10
10
|
<% if options.fullstaq -%>
|
11
|
-
FROM <%= platform %>quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-<%= options.jemalloc ? 'jemalloc-' : 'malloctrim-' %><%= variant %><% unless options.precompile == "defer" %>
|
11
|
+
FROM <%= platform %>quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-<%= options.jemalloc ? 'jemalloc-' : 'malloctrim-' %><%= variant %><% unless options.precompile == "defer" %> AS base<% end %>
|
12
12
|
<% else -%>
|
13
|
-
FROM <%= platform %><%= options.registry %>ruby:$RUBY_VERSION-<%= variant %><% unless options.precompile == "defer" %>
|
13
|
+
FROM <%= platform %><%= options.registry %>ruby:$RUBY_VERSION-<%= variant %><% unless options.precompile == "defer" %> AS base<% end %>
|
14
14
|
<% end -%>
|
15
15
|
|
16
16
|
<% unless options.label.empty? -%>
|
@@ -50,7 +50,7 @@ RUN gem update --system <% if RUBY_VERSION.start_with? '2' %>3.4.22 <% end %>--n
|
|
50
50
|
<% unless options.precompile == "defer" -%>
|
51
51
|
|
52
52
|
# Throw-away build stage<%= parallel? ? 's' : '' %> to reduce size of final image
|
53
|
-
FROM base
|
53
|
+
FROM base AS <%= parallel? ? 'pre' : '' %>build
|
54
54
|
|
55
55
|
<% end -%>
|
56
56
|
# Install packages needed to build gems<%= using_node? ? " and node modules" : "" %>
|
@@ -58,7 +58,7 @@ FROM base as <%= parallel? ? 'pre' : '' %>build
|
|
58
58
|
|
59
59
|
<% if parallel? -%>
|
60
60
|
|
61
|
-
FROM prebuild
|
61
|
+
FROM prebuild AS <% if using_bun? %>bun<% else %>node<% end %>
|
62
62
|
|
63
63
|
<% end -%>
|
64
64
|
<% if using_bun? and (!using_execjs? || File.exist?('bun.lockb')) -%>
|
@@ -72,7 +72,7 @@ FROM prebuild as <% if using_bun? %>bun<% else %>node<% end %>
|
|
72
72
|
<%= render partial: 'npm_install', locals: {sources: Dir[*%w(package.json yarn.lock bun.lockb)]} %>
|
73
73
|
|
74
74
|
|
75
|
-
FROM prebuild
|
75
|
+
FROM prebuild AS build
|
76
76
|
|
77
77
|
<% end -%>
|
78
78
|
<% unless build_args.empty? -%>
|
@@ -87,6 +87,9 @@ ENV <%= build_env.join(" \\\n ") %>
|
|
87
87
|
<% end -%>
|
88
88
|
# Install application gems
|
89
89
|
COPY<% if options.link? %> --link<% end %> Gemfile Gemfile.lock <% if references_ruby_version_file? %>.ruby-version <% end %>./
|
90
|
+
<% if @netpopbug && Rails.env != "test" -%>
|
91
|
+
RUN sed -i "/net-pop (0.1.2)/a\ net-protocol" Gemfile.lock
|
92
|
+
<% end -%>
|
90
93
|
<% if options.cache? -%>
|
91
94
|
RUN --mount=type=cache,id=bld-gem-cache,sharing=locked,target=/srv/vendor \
|
92
95
|
<% if private_gemserver_env_variable_name -%>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
version: "3.8"
|
2
|
+
|
2
3
|
services:
|
3
4
|
web:
|
4
5
|
<% if all_args.empty? -%>
|
@@ -18,11 +19,14 @@ services:
|
|
18
19
|
secrets:
|
19
20
|
- gemserver_credentials
|
20
21
|
<% end -%>
|
22
|
+
<% end -%>
|
23
|
+
volumes:
|
24
|
+
<% compose_web_volumes.each do |path| -%>
|
25
|
+
- ./<%= path %>:/rails/<%= path %>
|
21
26
|
<% end -%>
|
22
27
|
ports:
|
23
28
|
- "3000:3000"
|
24
29
|
environment:
|
25
|
-
- RAILS_MASTER_KEY=$RAILS_MASTER_KEY
|
26
30
|
<% if using_redis? -%>
|
27
31
|
- REDIS_URL=redis://redis-db:6379
|
28
32
|
<% end -%>
|
@@ -35,10 +39,9 @@ services:
|
|
35
39
|
- DATABASE_URL=mysql2://root:password@mysql-db/
|
36
40
|
<% end -%>
|
37
41
|
<% end -%>
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
<% end -%>
|
42
|
+
secrets:
|
43
|
+
- source: master_key
|
44
|
+
target: /rails/config/master.key
|
42
45
|
<% if using_redis? or deploy_database != 'sqlite3' -%>
|
43
46
|
depends_on:
|
44
47
|
<% if using_redis? -%>
|
@@ -60,9 +63,7 @@ services:
|
|
60
63
|
POSTGRES_USER: root
|
61
64
|
POSTGRES_PASSWORD: password
|
62
65
|
volumes:
|
63
|
-
- ./tmp/db:/var/lib/postgresql/data
|
64
|
-
ports:
|
65
|
-
- "5432:5432"
|
66
|
+
- ./tmp/postgres-db:/var/lib/postgresql/data
|
66
67
|
healthcheck:
|
67
68
|
test: pg_isready
|
68
69
|
interval: 2s
|
@@ -77,7 +78,7 @@ services:
|
|
77
78
|
environment:
|
78
79
|
MYSQL_ROOT_PASSWORD: password
|
79
80
|
volumes:
|
80
|
-
- ./tmp/db:/var/lib/mysql
|
81
|
+
- ./tmp/mysql-db:/var/lib/mysql
|
81
82
|
healthcheck:
|
82
83
|
test: mysqladmin ping -h 127.0.0.1 -u root --password=password
|
83
84
|
interval: 2s
|
@@ -132,3 +133,7 @@ secrets:
|
|
132
133
|
gemserver_credentials:
|
133
134
|
file: ./GEMSERVER_CREDENTIALS.secret.txt
|
134
135
|
<% end -%>
|
136
|
+
|
137
|
+
secrets:
|
138
|
+
master_key:
|
139
|
+
file: ./config/master.key
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockerfile-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -37,7 +37,6 @@ files:
|
|
37
37
|
- Rakefile
|
38
38
|
- lib/dockerfile-rails.rb
|
39
39
|
- lib/dockerfile-rails/scanner.rb
|
40
|
-
- lib/fly_replay.rb
|
41
40
|
- lib/generators/dockerfile_generator.rb
|
42
41
|
- lib/generators/templates/Dockerfile.erb
|
43
42
|
- lib/generators/templates/_apt_install.erb
|
@@ -75,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
74
|
- !ruby/object:Gem::Version
|
76
75
|
version: '0'
|
77
76
|
requirements: []
|
78
|
-
rubygems_version: 3.5.
|
77
|
+
rubygems_version: 3.5.18
|
79
78
|
signing_key:
|
80
79
|
specification_version: 4
|
81
80
|
summary: Dockerfile generator for Rails
|
data/lib/fly_replay.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Fly
|
4
|
-
class FlyReplay
|
5
|
-
def initialize(app)
|
6
|
-
@app = app
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
# replay /prometheus/* to the prom proxy in bubblegum
|
11
|
-
if env["PATH_INFO"].starts_with?("/prometheus")
|
12
|
-
return [307, { "Fly-Replay" => "app=flyio-bubblegum-api" }, []]
|
13
|
-
end
|
14
|
-
|
15
|
-
# replay /debug to the debug app. unsure if this is actually used
|
16
|
-
if env["PATH_INFO"].starts_with?("/debug")
|
17
|
-
return [307, { "Fly-Replay" => "app=debug" }, []]
|
18
|
-
end
|
19
|
-
|
20
|
-
@status, @headers, @response = @app.call(env)
|
21
|
-
|
22
|
-
context = OpenTelemetry::Trace.current_span.context
|
23
|
-
@headers["fly-trace-id"] = context.trace_id.unpack1("H*")
|
24
|
-
@headers["fly-span-id"] = context.span_id.unpack1("H*")
|
25
|
-
|
26
|
-
[@status, @headers, @response]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|