dockerfile-rails 1.6.18 → 1.6.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '06001664944f094c87433a52a0dcdb69fe820682478861d502923676e26f3c73'
4
- data.tar.gz: 4189db8d30eefd52ddf399368f60ea63d940325f143c506304f257b87301b508
3
+ metadata.gz: 770d93b1bee2aa9cec4832a7a03b6c3ed8ccbfb82ca6c19a28959ab38f5f4501
4
+ data.tar.gz: d19ba2048b0c6d2f5d92506ab29dd2c06bdf106d782b4ce3ca45d41c079306a0
5
5
  SHA512:
6
- metadata.gz: 46e8f29cdfdfd8b16feb8392e65c57e4d5a6ea60e2b596273f1c2af43cb4cb88ac969b0a25a2702e35c6c29422e5e557046aa30a1f9c12df3b1b8663d747c159
7
- data.tar.gz: 417cd9a7715a2769c9060f9f2438f6486a06362c662a9ea3dc254f2d842b5120e0fea78661eab18f2cc00529b2db5a0a18be5a44055d29e84f7cbca57ceeb009
6
+ metadata.gz: 9dab86fe342a82d18911f2a1fc2d7ec5de69f3b7b3326f1ea9c9fb2945049dbcdd39ac9c125ab524997c16af6f1422b0d73062dfd80ff13044a79b7f0e81996e
7
+ data.tar.gz: ef62d1ff9359b3e702c0e5a914e39edeeb594bf5c3cc9f5ff2ac8564b974e5ae2bd753f4949d69353a8caf5cdb2ed220daa27255589b0c8f991b60cefd4dbb47
data/lib/fly_replay.rb ADDED
@@ -0,0 +1,29 @@
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
@@ -331,6 +331,8 @@ class DockerfileGenerator < Rails::Generators::Base
331
331
 
332
332
  template "docker-compose.yml.erb", "docker-compose.yml" if options.compose
333
333
 
334
+ template "database.yml.erb", "config/database.yml" if fix_database_config
335
+
334
336
  if using_litefs?
335
337
  template "litefs.yml.erb", "config/litefs.yml"
336
338
 
@@ -1450,4 +1452,31 @@ private
1450
1452
 
1451
1453
  toml
1452
1454
  end
1455
+
1456
+ # if there are multiple production databases defined, allow them all to be
1457
+ # configured via DATABASE_URL.
1458
+ def fix_database_config
1459
+ yaml = IO.read("config/database.yml")
1460
+
1461
+ production = YAML.load(yaml, aliases: true)["production"]
1462
+ return unless production.is_a?(Hash) && production.values.all?(Hash)
1463
+ return if production.keys == [ "primary" ]
1464
+
1465
+ section = yaml[/^(production:.*?)(^\S|\z)/m, 1]
1466
+
1467
+ replacement = section.gsub(/( ).*?\n((\1\s+).*?\n)*/) do |subsection|
1468
+ spaces = $3
1469
+ name = subsection[/\w+/]
1470
+
1471
+ if /^ +url:/.match?(subsection)
1472
+ subsection
1473
+ elsif name == "primary"
1474
+ subsection + spaces + %(url: <%= ENV["DATABASE_URL"] %>\n)
1475
+ else
1476
+ subsection + spaces + %(url: <%= URI.parse(ENV["DATABASE_URL"]).tap { |url| url.path += "_#{name}" } if ENV["DATABASE_URL"] %>\n)
1477
+ end
1478
+ end
1479
+
1480
+ yaml.sub(section, replacement)
1481
+ end
1453
1482
  end
@@ -0,0 +1 @@
1
+ <%= fix_database_config %>
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.18
4
+ version: 1.6.19
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-09-23 00:00:00.000000000 Z
11
+ date: 2024-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -37,6 +37,7 @@ files:
37
37
  - Rakefile
38
38
  - lib/dockerfile-rails.rb
39
39
  - lib/dockerfile-rails/scanner.rb
40
+ - lib/fly_replay.rb
40
41
  - lib/generators/dockerfile_generator.rb
41
42
  - lib/generators/templates/Dockerfile.erb
42
43
  - lib/generators/templates/_apt_install.erb
@@ -45,6 +46,7 @@ files:
45
46
  - lib/generators/templates/_node_client.erb
46
47
  - lib/generators/templates/_npm_install.erb
47
48
  - lib/generators/templates/_passenger.erb
49
+ - lib/generators/templates/database.yml.erb
48
50
  - lib/generators/templates/docker-compose.yml.erb
49
51
  - lib/generators/templates/docker-entrypoint.erb
50
52
  - lib/generators/templates/dockerfile.yml.erb
@@ -74,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
76
  - !ruby/object:Gem::Version
75
77
  version: '0'
76
78
  requirements: []
77
- rubygems_version: 3.5.18
79
+ rubygems_version: 3.5.14
78
80
  signing_key:
79
81
  specification_version: 4
80
82
  summary: Dockerfile generator for Rails