dockerfile-rails 1.6.23 → 1.6.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/DEMO.md +1 -1
- data/lib/generators/dockerfile_generator.rb +86 -21
- data/lib/generators/templates/Dockerfile.erb +1 -1
- data/lib/generators/templates/docker-compose.yml.erb +1 -1
- metadata +2 -3
- 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: 749745baff7e3b0f67b72f9f94c2df9086c344c9665e2d67498c02c33cfbcbab
|
4
|
+
data.tar.gz: 1b62d4bcf87fd0872057ee0e796b8f529a3b29b811e13447e7ac7df60961ab80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a88d05eac975d08d6ad47766300a996740c56e7a273488c7ec4e3f59729841d3edf132d91740a82410b7e60aff8017fb5aeabd15095b7ea0673f3088d08dd49f
|
7
|
+
data.tar.gz: b78e868ec797f8c2bdb01e0afc7214e60b7a134414a06b15cc2151e8fcee62e6a59cfcbdde6898af22bb38a3742f4af433187b0e3aaa323c6dd85f956df3f012
|
data/DEMO.md
CHANGED
@@ -7,7 +7,7 @@ Rails provides a _smoke test_ for new applications that makes sure that you have
|
|
7
7
|
```bash
|
8
8
|
rails new demo --minimal
|
9
9
|
cd demo
|
10
|
-
echo 'Rails.application.routes.draw { root "rails/welcome#index" }'
|
10
|
+
echo 'Rails.application.routes.draw { root "rails/welcome#index" }' >> config/routes.rb
|
11
11
|
bundle add dockerfile-rails --optimistic --group development
|
12
12
|
bin/rails generate dockerfile
|
13
13
|
docker buildx build . -t rails-demo
|
@@ -333,10 +333,10 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
333
333
|
|
334
334
|
if fix_database_config
|
335
335
|
template "database.yml.erb", "config/database.yml",
|
336
|
-
force: File.exist?("fly.toml")
|
336
|
+
force: options.force? || File.exist?("fly.toml")
|
337
337
|
end
|
338
338
|
|
339
|
-
if
|
339
|
+
if solidq_launcher == :puma && !File.read("config/puma.rb").include?(":solid_queue")
|
340
340
|
append_to_file "config/puma.rb", "\n# Run the Solid Queue's supervisor\nplugin :solid_queue\n"
|
341
341
|
end
|
342
342
|
|
@@ -421,20 +421,12 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
421
421
|
end
|
422
422
|
|
423
423
|
if File.exist?("fly.toml")
|
424
|
-
env =
|
425
|
-
|
426
|
-
if (options.sqlite3? || @sqlite3) && !dockerfile.include?("DATABASE_URL")
|
427
|
-
env["DATABASE_URL"] = "sqlite3:///data/production.sqlite3"
|
428
|
-
end
|
429
|
-
|
430
|
-
if using_thruster? && !dockerfile.include?("HTTP_PORT")
|
431
|
-
env["HTTP_PORT"] = "8080"
|
432
|
-
end
|
424
|
+
env = fly_toml_env
|
433
425
|
|
434
426
|
unless env.empty?
|
435
427
|
toml = IO.read("fly.toml")
|
436
|
-
if !toml.include?("[
|
437
|
-
toml += "\n[
|
428
|
+
if !toml.include?("[env]")
|
429
|
+
toml += "\n[env]\n" + env.map { |key, value| " #{key} = #{value.inspect}" }.join("\n") + "\n"
|
438
430
|
File.write "fly.toml", toml
|
439
431
|
end
|
440
432
|
end
|
@@ -550,6 +542,22 @@ private
|
|
550
542
|
@gemfile.include?("solid_queue") and includes_jobs?
|
551
543
|
end
|
552
544
|
|
545
|
+
def solidq_launcher
|
546
|
+
if !using_solidq?
|
547
|
+
:none
|
548
|
+
elsif deploy_database != "sqlite3"
|
549
|
+
:process
|
550
|
+
elsif File.exist? "config/puma.rb"
|
551
|
+
if File.read("config/puma.rb").include?("SOLID_QUEUE_IN_PUMA")
|
552
|
+
File.exist?("fly.toml") ? :env : :none
|
553
|
+
else
|
554
|
+
:puma
|
555
|
+
end
|
556
|
+
else
|
557
|
+
:procfile
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
553
561
|
def parallel?
|
554
562
|
(using_node? || using_bun?) && options.parallel
|
555
563
|
end
|
@@ -990,6 +998,10 @@ private
|
|
990
998
|
env.merge! @@args["deploy"].to_h { |key, value| [key, "$#{key}"] }
|
991
999
|
end
|
992
1000
|
|
1001
|
+
if solidq_launcher == :env
|
1002
|
+
env["SOLID_QUEUE_IN_PUMA"] = "true"
|
1003
|
+
end
|
1004
|
+
|
993
1005
|
env.merge! @@vars["deploy"] if @@vars["deploy"]
|
994
1006
|
|
995
1007
|
env.map { |key, value| "#{key}=#{value.inspect}" }.sort
|
@@ -1216,23 +1228,35 @@ private
|
|
1216
1228
|
|
1217
1229
|
def procfile
|
1218
1230
|
if using_passenger?
|
1219
|
-
{
|
1231
|
+
base = {
|
1220
1232
|
nginx: "nginx"
|
1221
1233
|
}
|
1222
1234
|
elsif options.nginx?
|
1223
|
-
{
|
1235
|
+
base = {
|
1224
1236
|
nginx: '/usr/sbin/nginx -g "daemon off;"',
|
1225
1237
|
rails: "./bin/rails server -p 3001"
|
1226
1238
|
}
|
1227
1239
|
elsif using_thruster?
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1240
|
+
if File.exist? "bin/thrust"
|
1241
|
+
base = {
|
1242
|
+
rails: "./bin/thrust ./bin/rails server"
|
1243
|
+
}
|
1244
|
+
else
|
1245
|
+
base = {
|
1246
|
+
rails: "bundle exec thrust ./bin/rails server"
|
1247
|
+
}
|
1248
|
+
end
|
1231
1249
|
else
|
1232
|
-
{
|
1250
|
+
base = {
|
1233
1251
|
rails: "./bin/rails server"
|
1234
1252
|
}
|
1235
1253
|
end
|
1254
|
+
|
1255
|
+
if solidq_launcher == :procfile
|
1256
|
+
base["solidq"] = "bundle exec rake solid_queue:start"
|
1257
|
+
end
|
1258
|
+
|
1259
|
+
base
|
1236
1260
|
end
|
1237
1261
|
|
1238
1262
|
def using_thruster?
|
@@ -1241,7 +1265,7 @@ private
|
|
1241
1265
|
|
1242
1266
|
def fly_processes
|
1243
1267
|
return unless File.exist? "fly.toml"
|
1244
|
-
return unless using_sidekiq? || using_solidq?
|
1268
|
+
return unless using_sidekiq? || using_solidq? || using_thruster?
|
1245
1269
|
|
1246
1270
|
if procfile.size > 1
|
1247
1271
|
list = { "app" => "foreman start --procfile=Procfile.prod" }
|
@@ -1405,11 +1429,45 @@ private
|
|
1405
1429
|
end
|
1406
1430
|
end
|
1407
1431
|
|
1432
|
+
def fly_toml_env
|
1433
|
+
env = {}
|
1434
|
+
dockerfile = File.read("Dockerfile") rescue ""
|
1435
|
+
|
1436
|
+
if using_thruster?
|
1437
|
+
env["PORT"] = "8080"
|
1438
|
+
end
|
1439
|
+
|
1440
|
+
if (options.sqlite3? || @sqlite3) && !dockerfile.include?("DATABASE_URL")
|
1441
|
+
env["DATABASE_URL"] = "sqlite3:///data/production.sqlite3"
|
1442
|
+
end
|
1443
|
+
|
1444
|
+
if using_thruster? # && !dockerfile.include?("HTTP_PORT")
|
1445
|
+
# env["HTTP_PORT"] = "8080"
|
1446
|
+
env["PORT"] = "8080"
|
1447
|
+
end
|
1448
|
+
|
1449
|
+
if solidq_launcher == :env && !dockerfile.include?("SOLID_QUEUE_IN_PUMA")
|
1450
|
+
env["SOLID_QUEUE_IN_PUMA"] = "true"
|
1451
|
+
end
|
1452
|
+
|
1453
|
+
env
|
1454
|
+
end
|
1455
|
+
|
1408
1456
|
def fly_make_toml
|
1409
1457
|
toml = File.read("fly.toml")
|
1458
|
+
env = fly_toml_env
|
1459
|
+
|
1460
|
+
unless env.empty? || toml.include?("[env]")
|
1461
|
+
toml += "\n[env]\n" + env.map { |key, value| " #{key} = #{value.inspect}" }.join("\n") + "\n"
|
1462
|
+
end
|
1410
1463
|
|
1411
1464
|
list = fly_processes
|
1412
1465
|
if list
|
1466
|
+
if using_thruster?
|
1467
|
+
primary = list.keys.first
|
1468
|
+
list[primary] = list[primary].sub(/^.*thrust /, "")
|
1469
|
+
end
|
1470
|
+
|
1413
1471
|
if toml.include? "[processes]"
|
1414
1472
|
toml.sub!(/\[processes\].*?(\n\n|\n?\z)/m, "[processes]\n" +
|
1415
1473
|
list.map { |name, cmd| " #{name} = #{cmd.inspect}" }.join("\n") + '\1')
|
@@ -1434,7 +1492,14 @@ private
|
|
1434
1492
|
|
1435
1493
|
if deploy_database == "sqlite3"
|
1436
1494
|
if not toml.include? "[mounts]"
|
1437
|
-
toml += "
|
1495
|
+
toml += <<~EOF + "\n"
|
1496
|
+
[mounts]
|
1497
|
+
source = "data"
|
1498
|
+
destination = "/data"
|
1499
|
+
auto_extend_size_threshold = 80
|
1500
|
+
auto_extend_size_increment = "1GB"
|
1501
|
+
auto_extend_size_limit = "10GB"
|
1502
|
+
EOF
|
1438
1503
|
end
|
1439
1504
|
end
|
1440
1505
|
|
@@ -303,7 +303,7 @@ EXPOSE <%= using_thruster? ? '80' : '3000' %>
|
|
303
303
|
<% if deploy_database == 'sqlite3' -%>
|
304
304
|
VOLUME /data
|
305
305
|
<% end -%>
|
306
|
-
<% unless fly_processes -%>
|
306
|
+
<% unless fly_processes && !using_thruster? -%>
|
307
307
|
<% if !options.procfile.blank? -%>
|
308
308
|
CMD ["foreman", "start", "--procfile=<%= options.procfile %>"]
|
309
309
|
<% elsif procfile.size > 1 -%>
|
@@ -91,7 +91,7 @@ services:
|
|
91
91
|
redis-db:
|
92
92
|
image: redis
|
93
93
|
<% end -%>
|
94
|
-
<% if (using_sidekiq?
|
94
|
+
<% if (using_sidekiq? and deploy_database != 'sqlite3') or solidq_launcher == :process -%>
|
95
95
|
|
96
96
|
<%= using_sidekiq? ? "sidekiq" : "solidq" %>:
|
97
97
|
build: .
|
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.25
|
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-12-12 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
|
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
|