dockerfile-rails 1.6.18 → 1.6.20
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/README.md +1 -1
- data/lib/fly_replay.rb +29 -0
- data/lib/generators/dockerfile_generator.rb +32 -3
- data/lib/generators/templates/database.yml.erb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b00e2bf3497486dd4bde825bdf67c805f9e4f5293a7c9ba279ae559324f4a1
|
4
|
+
data.tar.gz: 1a1cb3c9fbadc0d6e28b332a9d5bdadb4354aa8a6924dccc353dfd698eb68d82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c916667f7f12930ede3c0279a852a7f32d2433f69acd69626630a71de2d206b5f36f9448ccf7db09097684f718ce29899741a442e506027fd260efc7b489095
|
7
|
+
data.tar.gz: 7f96dc124502e009d955e4886d0848775e962ccd935f165b4c71d6abc50e889b0f04da64ca0844038a913606b36dca33068f4bbb08e54c22343e05eba87c9a81
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ different contents. If both are specified, `--force` takes precedence.
|
|
52
52
|
* `--max-idle=n` - exit afer *n* seconds of inactivity. Supports [iso 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) and [sleep](https://man7.org/linux/man-pages/man1/sleep.1.html#DESCRIPTION) syntaxes. Uses passenger for now, awaiting [puma](https://github.com/puma/puma/issues/2580) support.
|
53
53
|
* `--nginx` - serve static files via [nginx](https://www.nginx.com/). May require `--root` on some targets to access `/dev/stdout`
|
54
54
|
* `--thruster` - serve static files via [thruster](https://github.com/basecamp/thruster?tab=readme-ov-file#thruster).
|
55
|
-
* `--
|
55
|
+
* `--link` - add [--link](https://docs.docker.com/engine/reference/builder/#copy---link) to COPY statements. Some tools (like at the moment, [buildah](https://www.redhat.com/en/topics/containers/what-is-buildah)) don't yet support this feature.
|
56
56
|
* `--no-lock` - don't add linux platforms, set `BUNDLE_DEPLOY`, or `--frozen-lockfile`. May be needed at times to work around a [rubygems bug](https://github.com/rubygems/rubygems/issues/6082#issuecomment-1329756343).
|
57
57
|
* `--sudo` - install and configure sudo to enable `sudo -iu rails` access to full environment
|
58
58
|
|
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
|
@@ -17,7 +17,7 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
17
17
|
"gemfile-updates" => true,
|
18
18
|
"jemalloc" => false,
|
19
19
|
"label" => {},
|
20
|
-
"link" =>
|
20
|
+
"link" => false,
|
21
21
|
"litefs" => false,
|
22
22
|
"lock" => true,
|
23
23
|
"max-idle" => nil,
|
@@ -117,7 +117,7 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
117
117
|
class_option :ci, type: :boolean, default: OPTION_DEFAULTS.ci,
|
118
118
|
desc: "include test gems in bundle"
|
119
119
|
|
120
|
-
class_option :link, type: :boolean, default: OPTION_DEFAULTS.
|
120
|
+
class_option :link, type: :boolean, default: OPTION_DEFAULTS.link,
|
121
121
|
desc: "use COPY --link whenever possible"
|
122
122
|
|
123
123
|
class_option :lock, type: :boolean, default: OPTION_DEFAULTS.lock,
|
@@ -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
|
|
@@ -522,7 +524,7 @@ private
|
|
522
524
|
end
|
523
525
|
|
524
526
|
def using_sidekiq?
|
525
|
-
@gemfile.include?("sidekiq")
|
527
|
+
@gemfile.include?("sidekiq")
|
526
528
|
end
|
527
529
|
|
528
530
|
def using_solidq?
|
@@ -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.
|
4
|
+
version: 1.6.20
|
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-
|
11
|
+
date: 2024-09-26 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.
|
79
|
+
rubygems_version: 3.5.14
|
78
80
|
signing_key:
|
79
81
|
specification_version: 4
|
80
82
|
summary: Dockerfile generator for Rails
|