dockerfile-rails 1.6.14 → 1.6.15

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: 2531120f4d41adf0dd6616bd2402b96236bbe88d29bb4ce68540807fe90ee9d7
4
- data.tar.gz: 6ce1bd73ea9ff3d999c11e8c0e22f00b4ed3324f5cca1b811b147a101ca9988a
3
+ metadata.gz: 408907e489bd861b56cdbf73efa0213276ffee3cd1edaab526e3e978325d6bb1
4
+ data.tar.gz: afedfb85e018faf90a4a84b712d0b0e8060e7c898868b02499a0bd87bce81984
5
5
  SHA512:
6
- metadata.gz: 300bf0e817f27b0f4972333d87bbe1b322c866e8e3eeaf5eb4bd689f69a584b992ecdf9c5d93299130cef292bf3666a637f353658a744593ef7e32b3f381f7fd
7
- data.tar.gz: c71043dc03cea93277164bc4ad4aa4e37712b76df6c40f65883bead0a8503f125f3a5f904c594ce8b6d26873a86fbee6b11deb2f0f58bc6daa2a1d9c106f514b
6
+ metadata.gz: a90b5fa2032eb15f8dacb12ccbe1f4fc711f8ebdd4a4f90b24291d146af948413783b484c3bc0054614e7deb9f5acff5a90cf9da96f1d86f9481b85146debf2b
7
+ data.tar.gz: d3db627db5dab2c89517cd8eaf34e66dbadb4b17ae43b5533fd4e6430e4372cc09f7ebb509c509281954cd1896fc42713947d2aec631557955a7488e52f562ee
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
@@ -42,6 +42,7 @@ class DockerfileGenerator < Rails::Generators::Base
42
42
  "sentry" => false,
43
43
  "sudo" => false,
44
44
  "swap" => nil,
45
+ "tigris" => false,
45
46
  "thruster" => false,
46
47
  "variant" => nil,
47
48
  "windows" => false,
@@ -161,6 +162,9 @@ class DockerfileGenerator < Rails::Generators::Base
161
162
  class_option :litefs, type: :boolean, default: OPTION_DEFAULTS.litefs,
162
163
  desc: "replicate sqlite3 databases using litefs"
163
164
 
165
+ class_option :tigris, type: :boolean, default: OPTION_DEFAULTS.tigris,
166
+ desc: "configure active storage to use tigris"
167
+
164
168
  class_option :postgresql, aliases: "--postgres", type: :boolean, default: OPTION_DEFAULTS.postgresql,
165
169
  desc: "include postgresql libraries"
166
170
 
@@ -372,6 +376,10 @@ class DockerfileGenerator < Rails::Generators::Base
372
376
  remove_file "config/dockerfile.yml"
373
377
  end
374
378
 
379
+ if options.tigris?
380
+ configure_tigris
381
+ end
382
+
375
383
  # check Dockerfile for common errors: missing packages, mismatched Ruby version;
376
384
  # also add DATABASE_URL to fly.toml if needed
377
385
  if options.skip? && File.exist?("Dockerfile")
@@ -548,6 +556,10 @@ private
548
556
  system "bundle add redis --skip-install" unless @gemfile.include? "redis"
549
557
  end
550
558
 
559
+ if options.tigris?
560
+ system "bundle add aws-sdk-s3 --require=false --skip-install" unless @gemfile.include? "aws-sdk-s3"
561
+ end
562
+
551
563
  if options.sentry?
552
564
  system "bundle add sentry-ruby --skip-install" unless @gemfile.include? "sentry-ruby"
553
565
  system "bundle add sentry-rails --skip-install" unless @gemfile.include? "sentry-rails"
@@ -994,7 +1006,7 @@ private
994
1006
  instructions = IO.read @@instructions["base"]
995
1007
 
996
1008
  if instructions.start_with? "#!"
997
- instructions = "# custom instructions\nRUN #{@instructions["base"].strip}"
1009
+ instructions = "# custom instructions\nRUN #{@@instructions["base"].strip}"
998
1010
  end
999
1011
 
1000
1012
  instructions.html_safe
@@ -1006,7 +1018,7 @@ private
1006
1018
  instructions = IO.read @@instructions["build"]
1007
1019
 
1008
1020
  if instructions.start_with? "#!"
1009
- instructions = "# custom build instructions\nRUN #{@instructions["build"].strip}"
1021
+ instructions = "# custom build instructions\nRUN #{@@instructions["build"].strip}"
1010
1022
  end
1011
1023
 
1012
1024
  instructions.html_safe
@@ -1018,7 +1030,7 @@ private
1018
1030
  instructions = IO.read @@instructions["deploy"]
1019
1031
 
1020
1032
  if instructions.start_with? "#!"
1021
- instructions = "# custom deploy instructions\nRUN #{@instructions["deploy"].strip}"
1033
+ instructions = "# custom deploy instructions\nRUN #{@@instructions["deploy"].strip}"
1022
1034
  end
1023
1035
 
1024
1036
  instructions.html_safe
@@ -1299,6 +1311,49 @@ private
1299
1311
  system "#{flyctl} consul attach"
1300
1312
  end
1301
1313
 
1314
+ def configure_tigris
1315
+ return unless options.tigris?
1316
+
1317
+ service = [
1318
+ "tigris:",
1319
+ " service: S3",
1320
+ ' access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %>',
1321
+ ' secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %>',
1322
+ ' endpoint: <%= ENV["AWS_ENDPOINT_URL_S3"] %>',
1323
+ ' bucket: <%= ENV["BUCKET_NAME"] %>'
1324
+ ]
1325
+
1326
+ shell = Thor::Base.shell.new
1327
+
1328
+ if File.exist?("config/storage.yml")
1329
+ storage = IO.read("config/storage.yml")
1330
+ if storage.include? "tigris"
1331
+ STDOUT.puts shell.set_color("unchanged".rjust(12), Thor::Shell::Color::BLUE, Thor::Shell::Color::BOLD) +
1332
+ " config/storage.yml"
1333
+ else
1334
+ storage = storage.strip + "\n\n" + service.join("\n") + "\n"
1335
+ IO.write("config/storage.yml", storage)
1336
+ STDOUT.puts shell.set_color("updated".rjust(12), Thor::Shell::Color::GREEN, Thor::Shell::Color::BOLD) +
1337
+ " config/storage.yml"
1338
+ end
1339
+ end
1340
+
1341
+ if File.exist?("config/environments/production.rb")
1342
+ production = IO.read("config/environments/production.rb")
1343
+ if !production.include?("tigris") && production.include?("config.active_storage.service")
1344
+ production.sub!(/config.active_storage.service.*/, "config.active_storage.service = :tigris")
1345
+ production.sub! "# Store uploaded files on the local file system",
1346
+ "# Store uploaded files in Tigris Global Object Storage"
1347
+ IO.write("config/environments/production.rb", production)
1348
+ STDOUT.puts shell.set_color("updated".rjust(12), Thor::Shell::Color::GREEN, Thor::Shell::Color::BOLD) +
1349
+ " config/environments/production.rb"
1350
+ else
1351
+ STDOUT.puts shell.set_color("unchanged".rjust(12), Thor::Shell::Color::BLUE, Thor::Shell::Color::BOLD) +
1352
+ " config/environments/production.yml"
1353
+ end
1354
+ end
1355
+ end
1356
+
1302
1357
  def fly_make_toml
1303
1358
  toml = File.read("fly.toml")
1304
1359
 
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.14
4
+ version: 1.6.15
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-05-27 00:00:00.000000000 Z
11
+ date: 2024-06-05 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.10
78
+ rubygems_version: 3.5.9
78
79
  signing_key:
79
80
  specification_version: 4
80
81
  summary: Dockerfile generator for Rails