dockerfile-rails 1.6.9 → 1.6.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8273f4e7e16fa5763ebfee285648dfede6ec020e51d51e3e9b8caf5b70333aba
4
- data.tar.gz: 16824fb5f76c53dcf5fb0ebca40335591def91034e9cdfea59d12f0b44fb1fed
3
+ metadata.gz: 38dcdef2aee6ee5c058a39c20f94dd1a786cebd4ae13b73c04ce105af60b1227
4
+ data.tar.gz: 491eb04d414d7a97268eddb82d5637997cd6bafe84ff8ae04c5c859ffbf62353
5
5
  SHA512:
6
- metadata.gz: 682c85b4a0a4d5e7157e39bb300b17ec4eff7be7beb98a6431b74d36d7e4f0dfa3d9b3bb81bfe5d31852423fc750595366ca503b9a44ac05a83acb5187afe1c1
7
- data.tar.gz: c015796534771823bf606a22165d76899dd21745ac580d6bcc0b8aa780ef0ddf1427818536120616bf91eb3ea686838cf5f42b718b5d36804db6f59b3abc2a58
6
+ metadata.gz: 9404ac27ff75311447320c4a0092a11dda3bd82fb7db8b369ccbb65efb7f291b445ea3d8867c8247baad9fb2efbe8f7aa9437c1a02529add19bdf416b4f5ff8c
7
+ data.tar.gz: 0703e28305e99057211826a13ba2d8992d52238fbaeb4b71e10a29ab2f3f130ae7efc91248f663bb1e4215b1b0bc484bcf05a6ad0a1842f93d76b3fce229ca76
data/README.md CHANGED
@@ -103,7 +103,8 @@ Args and environment variables can be tailored to a specific build phase by addi
103
103
  There may be times where feature detection plus flags just aren't enough. As an example, you may wish to configure and run multiple processes.
104
104
 
105
105
  * `--instructions=path` - a dockerfile fragment to be inserted into the final document.
106
- * `--migration=cmd` - a replacement (generally a script) for `db:prepare`/`db:migrate`.
106
+ * `--migrate=cmd` - a replacement (generally a script) for `db:prepare`/`db:migrate`.
107
+ * `--no-gemfile-updates` - do not modify my gemfile.
107
108
  * `--procfile=path` - a [Procfile](https://github.com/ddollar/foreman#foreman) to use in place of launching Rails directly.
108
109
 
109
110
  Like with environment variables, packages, and build args, `--instructions` can be tailored to a specific build phase by adding `-base`, `-build`, or `-deploy` after the flag name, with the default being `-deploy`.
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
@@ -14,6 +14,7 @@ class DockerfileGenerator < Rails::Generators::Base
14
14
  "ci" => false,
15
15
  "compose" => false,
16
16
  "fullstaq" => false,
17
+ "gemfile-updates" => true,
17
18
  "jemalloc" => false,
18
19
  "label" => {},
19
20
  "link" => true,
@@ -219,6 +220,9 @@ class DockerfileGenerator < Rails::Generators::Base
219
220
  class_option "private-gemserver-domain", type: :string, default: OPTION_DEFAULTS["private-gemserver-domain"],
220
221
  desc: "domain name of a private gemserver used when installing application gems"
221
222
 
223
+ class_option "gemfile-updates", type: :boolean, default: OPTION_DEFAULTS["gemfile-updates"],
224
+ desc: "include gemfile updates"
225
+
222
226
 
223
227
  class_option "add-base", type: :array, default: [],
224
228
  desc: "additional packages to install for both build and deploy"
@@ -364,6 +368,30 @@ class DockerfileGenerator < Rails::Generators::Base
364
368
  elsif File.exist? "config/dockerfile.yml"
365
369
  remove_file "config/dockerfile.yml"
366
370
  end
371
+
372
+ # check Dockerfile for common errors: missing packages, mismatched Ruby version
373
+ if options.skip? && File.exist?("Dockerfile")
374
+ message = nil
375
+ shell = Thor::Base.shell.new
376
+
377
+ dockerfile = IO.read("Dockerfile")
378
+ missing = Set.new(base_packages + build_packages) -
379
+ Set.new(dockerfile.scan(/[-\w]+/))
380
+
381
+ unless missing.empty?
382
+ message = "The following packages are missing from the Dockerfile: #{missing.to_a.join(", ")}"
383
+ STDERR.puts "\n" + shell.set_color(message, Thor::Shell::Color::RED, Thor::Shell::Color::BOLD)
384
+ end
385
+
386
+ ruby_version = dockerfile.match(/ARG RUBY_VERSION=(\d+\.\d+\.\d+)/)[1]
387
+
388
+ if ruby_version && ruby_version != RUBY_VERSION
389
+ message = "The Ruby version in the Dockerfile (#{ruby_version}) does not match the Ruby version of the Rails app (#{RUBY_VERSION})"
390
+ STDERR.puts "\n" + shell.set_color(message, Thor::Shell::Color::RED, Thor::Shell::Color::BOLD)
391
+ end
392
+
393
+ exit 42 if message
394
+ end
367
395
  end
368
396
 
369
397
  private
@@ -486,6 +514,8 @@ private
486
514
  end
487
515
 
488
516
  def install_gems
517
+ return unless options["gemfile-updates"]
518
+
489
519
  ENV["BUNDLE_IGNORE_MESSAGES"] = "1"
490
520
 
491
521
  gemfile = IO.read("Gemfile")
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.9
4
+ version: 1.6.11
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-04-25 00:00:00.000000000 Z
11
+ date: 2024-05-08 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
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubygems_version: 3.5.4
78
+ rubygems_version: 3.5.9
78
79
  signing_key:
79
80
  specification_version: 4
80
81
  summary: Dockerfile generator for Rails